SwiftUI: Layout & Interfaces

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

Part 2: Aligning Views

14. Challenge: Custom Alignment Guides

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: 13. Custom Alignment Next episode: 15. ZStacks

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: 14. Challenge: Custom Alignment Guides

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

Heads up... You've reached locked video content where the transcript will be shown as obfuscated text.

This is a screenshot from the language learning app Duolingo. Duo is its owl mascot, and your coach. When using the app regularly, you amass gems. And in the Shop tab, you can trade them in for outfits for Duo to wear. In this episode, you’ll be recreating a layout inspired by this shop.

Image(razémon.name)
          .scaledToFit()
          .frame(width: 120)

        Text("name")
Text(razémon.name) 
razémon.description
Text("💎 \(razémon.cost)")
VStack(alignment: .leading, spacing: 15) {
}

extension Razémon: AlignmentID {

}

struct ContentView_Previews: PreviewProvider {
extension Razémon: AlignmentID {
  static func defaultValue(in context: ViewDimensions) -> CGFloat {
    context[.top]
  }
}
extension VerticalAlignment {
  static let raz
}
static let razémon 
static let razémon = Self(Razémon.self)
      HStack(alignment: .razémon) {
          Text(razémon.description)
            .alignmentGuide(<#T##g: VerticalAlignment##VerticalAlignment#>, computeValue: <#T##(ViewDimensions) -> CGFloat#>)
            .alignmentGuide(.razémon, computeValue: <#T##(ViewDimensions) -> CGFloat#>)
            .alignmentGuide(
              .razémon,
              computeValue: Razémon.defaultValue
            )
          .frame(width: 120)
          .alignmentGuide(.razémon) {

          }
          .alignmentGuide(.razémon) {
            $0[.bottom]
          }
razémon.eyePosition * $0[.bottom]
import AlignmentExtensions
extension Razémon: SingleAxisAlignmentID {

typealias Alignment = VerticalAlignment
.alignmentGuide(Razémon.self)