Skip to content

Implement EmptyModifier #28

@jverkoey

Description

@jverkoey

SwiftUI documentation for the same type: https://developer.apple.com/documentation/swiftui/emptymodifier:

Use the empty modifier to switch modifiers at compile time during development. In the example below, in a debug build the Text view inside ContentView has a yellow background and a red border. A non-debug build reflects the default system, or container supplied appearance.

struct EmphasizedLayout: ViewModifier {
    func body(content: Content) -> some View {
        content
            .background(Color.yellow)
            .border(Color.red)
    }
}


struct ContentView: View {
    var body: some View {
        Text("Hello, World!")
            .modifier(modifier)
    }


    var modifier: some ViewModifier {
        #if DEBUG
            return EmphasizedLayout()
        #else
            return EmptyModifier()
        #endif
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions