ericlewis / swiftui-viewmodifierbuilder

A result builder for ViewModifiers.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ViewModifierBuilder

A result builder for ViewModifiers.

Example

import SwiftUI
import ViewModifierBuilder

struct ContentView: View {

  @State
  private var toggler = false
  
  var body: some View {
    VStack {
      Button("Toggle Modifier") {
        toggler.toggle()
      }
    }
    .modifiers {
      CustomModifier1()
      CustomModifier2()
      if toggler {
        CustomModifier3()
      }
    }
  }
}

About

A result builder for ViewModifiers.


Languages

Language:Swift 100.0%