Skip to content

Instantly share code, notes, and snippets.

@caiobzen
Created September 25, 2019 00:15
Show Gist options
  • Save caiobzen/f6048c83768e8f509efd6c484aa18374 to your computer and use it in GitHub Desktop.
Save caiobzen/f6048c83768e8f509efd6c484aa18374 to your computer and use it in GitHub Desktop.
Waving Wrapper view
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