GregLeck

Modifiers1

Oct 17th, 2019
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 0.67 KB | None | 0 0
  1. // CONDITIONAL MODIFIERS & ENVIRONMENT MODIFIERS
  2. // & VIEWS AS PROPERTIES
  3. struct ContentView: View {
  4.    
  5.     @State private var useRedText = false
  6.    
  7.     let statement = Text("Using View as Properties!")
  8.    
  9.     var body: some View {
  10.         VStack {
  11.             Button("Red or Blue") {
  12.                 self.useRedText.toggle()
  13.             }
  14.             .foregroundColor(useRedText ? .blue : .red)
  15.            
  16.             VStack {
  17.                 Text("This is some text")
  18.                 Text("that will be modified")
  19.                 Text("by an environment modifier")
  20.                 statement
  21.             }
  22.             .font(.headline)
  23.         }
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment