Swift UI Project 3, Day 1

Posted on Fri 25 June 2021 in swift

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()
    }
}