Created
          July 11, 2022 14:56 
        
      - 
      
- 
        Save siracusa/5beb23628c7ab0fb8cc646862c557cb3 to your computer and use it in GitHub Desktop. 
    SwiftUI .if modifier
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | extension View { | |
| @ViewBuilder | |
| func `if`<Content: View>(_ conditional: Bool, @ViewBuilder content: (Self) -> Content) -> some View { | |
| if conditional { | |
| content(self) | |
| } | |
| else { | |
| self | |
| } | |
| } | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment