Created
July 4, 2020 08:23
-
-
Save CastIrony/2f1828af382307eba980fa01082b56f4 to your computer and use it in GitHub Desktop.
This file contains 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 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