Created
September 22, 2021 14:10
-
-
Save ozgurshn/3b8e94baa5fbb1fec91cf8da90594e2c to your computer and use it in GitHub Desktop.
SwiftUI hug content, take parameter to extracted view and put elements inside
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 | |
struct SubscriptionView: View { | |
var body: some View { | |
AppBackgroundView{ | |
Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/) | |
} | |
} | |
} | |
struct SubscriptionView_Previews: PreviewProvider { | |
static var previews: some View { | |
SubscriptionView() | |
} | |
} | |
struct AppBackgroundView<Content:View>: View | |
{ | |
let viewBuilder: () -> Content | |
var body: some View | |
{ | |
ZStack | |
{ | |
Color.blue | |
viewBuilder() | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment