Skip to content

Instantly share code, notes, and snippets.

@CastIrony
Created July 4, 2020 08:23
Show Gist options
  • Save CastIrony/2f1828af382307eba980fa01082b56f4 to your computer and use it in GitHub Desktop.
Save CastIrony/2f1828af382307eba980fa01082b56f4 to your computer and use it in GitHub Desktop.
import SwiftUI
struct ContentView: View
{
@State var angle: CGFloat = 0
let colors: [Color] = [ .red, .orange, .yellow, .green, .blue, .purple ]
let columns = [ GridItem(.adaptive(minimum: 140), alignment: .leading) ]
let animation = Animation.linear(duration: 10).repeatForever(autoreverses: false)
var body: some View
{
RoundedRectangle(cornerRadius: 25.0, style: .continuous)
.fill(Color.red)
.frame(width: 200, height: 200, alignment: .center)
.shadow(color: .black, radius: 10, x: (angle) * 10, y: (angle) * 10)
.onAppear
{
withAnimation(animation)
{
angle = CGFloat.pi * 2
}
}
}
}
struct ContentView_Previews: PreviewProvider
{
static var previews: some View
{
Group
{
ContentView()
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment