Last active
October 19, 2020 05:47
-
-
Save amosgyamfi/1f3b832ec383f4ec4eba06e530fcf872 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 | |
import PlaygroundSupport | |
struct ContentView: View { | |
@State private var topRotates = false | |
@State private var middleIsHidden = false | |
@State private var bottomRotates = false | |
var body: some View { | |
VStack(alignment: .center, spacing: 25){ | |
Rectangle() // top | |
.frame(width: 120, height: 20) | |
.cornerRadius(4) | |
.rotationEffect(.degrees(topRotates ? 48 : 0), anchor: .leading) | |
Rectangle() // middle | |
.frame(width: 120, height: 20) | |
.cornerRadius(4) | |
.scaleEffect(middleIsHidden ? 0 : 1) | |
.opacity(middleIsHidden ? 0 : 1) | |
Rectangle() // bottom | |
.frame(width: 120, height: 20) | |
.cornerRadius(4) | |
.rotationEffect(.degrees(bottomRotates ? -48 : 0), anchor: .leading) | |
}.animation( | |
Animation.interpolatingSpring(stiffness: 300, damping: 15)) | |
.onTapGesture { | |
self.topRotates.toggle() | |
self.bottomRotates.toggle() | |
self.middleIsHidden.toggle() | |
} | |
} | |
} | |
let ContentView_Previews = ContentView() | |
let vc = UIHostingController(rootView: ContentView_Previews) | |
PlaygroundPage.current.liveView = vc | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment