Created
May 14, 2020 19:18
-
-
Save navsing/fcb7b96c59614c94365e30d8229fefe0 to your computer and use it in GitHub Desktop.
let’s recreate the breathe app in less than 3 minutes using SwiftUI and Swift Playgrounds on iPad
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
struct Breathe: View { | |
@State var scale = false | |
@State var rotate = false | |
var body: some View { | |
ZStack { | |
Group { | |
ZStack { | |
Circle().frame(width: 80, height: 80).foregroundColor(Color(UIColor.systemBlue)).offset(y: -42) | |
Circle().frame(width: 80, height: 80).foregroundColor(Color(UIColor.systemBlue)).offset(y: 42) | |
} | |
}.opacity(1/3) | |
Group { | |
ZStack { | |
Circle().frame(width: 80, height: 80).foregroundColor(Color(UIColor.systemBlue)).offset(y: -42) | |
Circle().frame(width: 80, height: 80).foregroundColor(Color(UIColor.systemBlue)).offset(y: 42) | |
} | |
}.rotationEffect(.degrees(60)).opacity(1/4) | |
Group { | |
ZStack { | |
Circle().frame(width: 80, height: 80).foregroundColor(Color(UIColor.systemBlue)).offset(y: -42) | |
Circle().frame(width: 80, height: 80).foregroundColor(Color(UIColor.systemBlue)).offset(y: 42) | |
} | |
}.rotationEffect(.degrees(120)).opacity(1/2) | |
}.rotationEffect(.degrees(rotate ? 180 : 0)).scaleEffect(scale ? 1 : 1/8).animation(Animation.easeInOut.repeatForever(autoreverses: true).speed(1/8)).onAppear() { | |
self.rotate.toggle() | |
self.scale.toggle() | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment