GregLeck

Custom Modifiers

Oct 17th, 2019
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 0.44 KB | None | 0 0
  1. // CUSTOM MODIFIERS
  2. struct Title: ViewModifier {
  3.     func body(content: Content) -> some View {
  4.         HStack {
  5.         content
  6.             .font(.largeTitle)
  7.             .foregroundColor(.blue)
  8.         }
  9.     }
  10. }
  11.  
  12. extension View {
  13.     func bigBlueTitle() -> some View {
  14.         self.modifier(Title())
  15.     }
  16. }
  17.  
  18. struct CustomModifiers: View {
  19.     var body: some View {
  20.         Text("Hello World!"/)
  21.         .bigBlueTitle()
  22.     }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment