Alex Does Things Poorly

Alex does a variety of things poorly - swift, data science, datavis, ML, drawing, AR, unity, etc, etc.

25 June 2021

Swift UI Project 3, Day 1

by alex

More 100 Days of SwiftUI today, learning some fundamentals for how SwiftUI actually does things under the hood.

Mostly review for me, but it was cool to go over custom view composition again since that’s something I haven’t done in a while. One thing new for me, I didn’t realize how easy it was to make custom modifiers, so much fun!

struct WeddingModifier: ViewModifier {
    func body(content: Content) -> some View {
        content
            .font(.custom("Zapfino", size: 24))
    }
}

extension Text {
    func weddingText() -> some View {
        self.modifier(WeddingModifier())
    }
}

struct MyView: View {
    var body: some View {
        Text("Hello, World")
            .weddingText()
    }
}
tags: swift - swiftui