SwiftUI: Layout & Interfaces

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

Part 2: Aligning Views

11. Challenge: Align Nested Stacks

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: 10. Stack Alignment Next episode: 12. Alignment Guides

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: 11. Challenge: Align Nested Stacks

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

In this episode, you’ll be recreating a layout from my favorite Twitter client: Tweetbot.

      Image("RW")
        .resizable()

      Text("Following")
.frame(width: 90.0, height: 90.0)
.frame(width: 90, height: 90)
  var body: some View {
    let cornerRadius

    VStack {
let cornerRadius: CGFloat
let cornerRadius: CGFloat = 7.5
return VStack {
.frame(width: 90, height: 90)
.cornerRadius(cornerRadius)
.cornerRadius(cornerRadius)
.overlay(/*@START_MENU_TOKEN@*/ /*@PLACEHOLDER=Overlay Content@*/Text("Placeholder")/*@END_MENU_TOKEN@*/)
        .overlay(
          RoundedRectangle(cornerRadius: <#T##CGFloat#>)
        )
        .overlay(
          RoundedRectangle(cornerRadius: cornerRadius)
        )
          RoundedRectangle(cornerRadius: cornerRadius)
            .stroke(
.stroke(Color.white, lineWidth: <#T##CGFloat#>)
.stroke(Color.white, lineWidth: 2.5)
        )

      Text("Following")
        .font(.body)
        .fontWeight(.bold)
        .foregroundColor(Color.white)

      Text("raywenderlich.com")
.foregroundColor(.white)
.background( Color.blue )
        .background( Color.blue )
        .padding(., <#T##length: CGFloat?##CGFloat?#>)
.padding(.vertical, <#T##length: CGFloat?##CGFloat?#>)
.padding(.vertical, 4)
        .foregroundColor(.white)
        .padding(.vertical, 4)
        .background( Color.blue )
        .foregroundColor(.white)
        .padding(.horizontal, 10)
        .padding(.vertical, 4)
.clipShape(<#T##shape: Shape##Shape#>)
        .background( Color.blue )
        .clipShape( Capsule() )

      Text("raywenderlich.com")
      Text("raywenderlich.com")
        .font(.headline)
        .foregroundColor(.white)
      Text("@rwenderlich")
        .font(.subheadline)
        .foregroundColor(.white)
.font(.caption)
      Text("FOLLOWS YOU")
        .font(.caption)
        .foregroundColor(<#T##color: Color?##Color?#>)

      Text(
.foregroundColor( .init(white: 0.4) )
.background( Color(white: 0.9) )
.clipShape( Capsule() )
        .foregroundColor( .init(white: 0.4) )
        .padding(.horizontal, 10)
        .background( Color(white: 0.9) )
.padding(.top, 5)
        .padding(.top, 5)
        .lineSpacing(<#T##lineSpacing: CGFloat##CGFloat#>)
    }
.lineSpacing(-.infinity)
    return HStack {
      VStack {
          .clipShape( Capsule() )
      }

        Text("raywenderlich.com")
      }

      VStack {
        Text("raywenderlich.com")
      VStack(alignment: .leading) {
        Text("raywenderlich.com")
        HStack {
          Text("@rwenderlich")
            .font(.subheadline)
            .foregroundColor(.white)
        }
            .foregroundColor(.white)

          Text("FOLLOWS YOU")
            .font(.caption)
            .foregroundColor( .init(white: 0.4) )
            .padding(.horizontal, 10)
            .background( Color(white: 0.9) )
            .clipShape( Capsule() )
        }

        Text(
HStack(alignment: .center) {
HStack(alignment: .lastTextBaseline) {
        Text(
          "We are a friendly and supportive community of mobile developers. "
//            + "We love to learn and share our knowledge with the world! "
//            + "raywenderlich.com"
        )
            + "We love to learn and share our knowledge with the world! "
            + "raywenderlich.com"
return HStack(alignment: .top) {