Created
September 25, 2019 00:15
-
-
Save caiobzen/f6048c83768e8f509efd6c484aa18374 to your computer and use it in GitHub Desktop.
Waving Wrapper view
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 WavingBackground <Content: View>: View { | |
private let content: Content | |
private var fill: CGFloat | |
public init(fill: CGFloat = .zero, @ViewBuilder content: () -> Content) { | |
self.fill = fill | |
self.content = content() | |
} | |
var body: some View { | |
ZStack { | |
// All the waves and filling rectangle stuff | |
content // <- This represents whatever you want to render within this view :) | |
} | |
} | |
} | |
struct WavingBackground_Previews: PreviewProvider { | |
static var previews: some View { | |
WavingBackground(fill: 60) { | |
Text("Hey!") | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment