SwiftUI: Layout & Interfaces

Nov 18 2021 · Swift 5.5, iOS 15, Xcode 13

Part 2: Aligning Views

16. GeometryReader

Episode complete

Play next episode

Next
About this episode

Leave a rating/review

See forum comments
Cinema mode Mark complete Download course materials
Previous episode: 15. ZStacks Next episode: 17. Challenge: 3-Axis Layout

Get immediate access to this and 4,000+ other videos and books.

Take your career further with a Kodeco Personal Plan. With unlimited access to over 40+ books and 4,000+ professional videos in a single subscription, it's simply the best investment you can make in your development career.

Learn more Already a subscriber? Sign in.

Notes: 16. GeometryReader

This course was originally recorded in 2019. It has been reviewed and all content and materials updated as of October 2021.

Heads up... You’re accessing parts of this content for free, with some sections shown as obfuscated text.

Heads up... You’re accessing parts of this content for free, with some sections shown as obfuscated text.

Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.

Unlock now

With what you know about Stacks in SwiftUI by now, you have access to …gigawatts of power. But there’s one more tool I want to leave you with, that pairs well with Stacks: the GeometryReader.

        .scaledToFit()
        .frame(width: 250)
      Text("Reading is dreaming with open eyes.")
        .scaledToFit()
    }
      .frame(width: 250)
  }
    Group {
      HStack {
        Image("Cake VStack")
          .resizable()
          .scaledToFit()
          .frame(width: 250)
        Text("Reading is dreaming with open eyes.")
        Image("Pancake VStack")
          .resizable()
          .scaledToFit()
      }
      .frame(width: 250)
    }
  var body: some View {
    GeometryReader {
      HStack {
GeometryReader { proxy in
.frame(width: proxy.size)
.frame(width: proxy.size.width * 0.5)
          .scaledToFit()
      }
    }
      .frame(width: 250)
  }
          .scaledToFit()
      }
    }
        Text("Reading is dreaming with open eyes.")
          .layoutPriority(1)
        Image("Pancake VStack")