Skip to content

YamamotoDesu/ViewModifierExtension

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

Using ViewModifier

struct TitleModifier: ViewModifier {

    func body(content: Content) -> some View {
        content
            .font(.largeTitle)
    }

}
    var body: some View {
        Text("Bigger Text")
            .modifier(TitleModifier())
    }

Using extension(much simpler💡)

extension View {

    func title() -> some View {
        self
            .font(.largeTitle)
    }

}
    var body: some View {
        Text("Bigger Text")
            .title()
    }