Created
December 1, 2019 02:21
-
-
Save Bradysm/baea0f53acaeeddf9164f2aa22e5270f 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
// | |
// ExampleCard.swift | |
// PopQuiz WatchKit Extension | |
// | |
// Created by brady murphy on 11/30/19. | |
// Copyright © 2019 Apple. All rights reserved. | |
// | |
import SwiftUI | |
struct ExampleCard: View { | |
@State var flipped = false // state variable used to update the card | |
var body: some View { | |
RoundedRectangle(cornerRadius: 20) | |
.foregroundColor(self.flipped ? .red : .blue) // change the card color when flipped | |
.padding() | |
.rotation3DEffect(self.flipped ? Angle(degrees: 180): Angle(degrees: 0), axis: (x: CGFloat(0), y: CGFloat(10), z: CGFloat(0))) | |
.animation(.default) // implicitly applying animation | |
.onTapGesture { | |
// explicitly apply animation on toggle (choose either or) | |
//withAnimation { | |
self.flipped.toggle() | |
//} | |
} | |
} | |
} | |
struct ExampleCard_Previews: PreviewProvider { | |
static var previews: some View { | |
ExampleCard() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment