Created
June 22, 2021 23:42
-
-
Save benlmyers/68fd4de9090cb18dfd8d70775c3821b4 to your computer and use it in GitHub Desktop.
A quick way to add together views using the + operator.
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
import SwiftUI | |
extension View { | |
static func + <T> (lhs: Self, rhs: T) -> some View where T: View { | |
HStack { | |
lhs | |
rhs | |
} | |
} | |
} | |
/// Example of using this operator: | |
/// ``` | |
/// Image(systemName: "hand.wave") + Text("Hello, quicker SwiftUI!") | |
/// ``` | |
/// Views added together are quickly embedded in an HStack. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment