Skip to content

Instantly share code, notes, and snippets.

@jmcd
Created February 18, 2020 18:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jmcd/b916ec21beff2f07261cb3db6cd432d8 to your computer and use it in GitHub Desktop.
Save jmcd/b916ec21beff2f07261cb3db6cd432d8 to your computer and use it in GitHub Desktop.
import SwiftUI
struct ContentView: View {
@State var gradient = [
Color.red, .orange, .yellow, .green, .blue, .purple, Color.red, .orange, .yellow, .green, .blue, .purple,
]
@State var startPoint = UnitPoint(x: 0, y: -1)
@State var endPoint = UnitPoint(x: 0, y: 1)
var body: some View {
ZStack(alignment: .center) {
LinearGradient(
gradient: Gradient(colors: gradient),
startPoint: startPoint,
endPoint: endPoint
)
.mask(
HStack {
Spacer()
VStack {
Spacer()
Text("stormid").font(Font(UIFont(name: "CenturySchoolbook", size: 200)!))
Spacer()
}
Spacer()
}
)
.background(Color.black)
.onAppear {
withAnimation(Animation.easeInOut(duration: 2)
.repeatForever(autoreverses: true)
) {
self.startPoint = UnitPoint(x: 0, y: 0)
self.endPoint = UnitPoint(x: 2, y: 0)
}
}
}.edgesIgnoringSafeArea(.all)
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment