Last active
August 27, 2021 06:26
-
-
Save amosgyamfi/c99f7ff83bb1cb5266192b1e33f0fb1a 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
// | |
// ContentView.swift | |
// DoubleTapToZoom | |
// | |
// Created by Amos Gyamfi on 26.8.2021. | |
// | |
import SwiftUI | |
struct ContentView: View { | |
// Animation start value | |
@State private var zoomed = false | |
var body: some View { | |
Image("cooking") | |
.resizable() | |
.aspectRatio(contentMode: .fit) | |
.scaleEffect(zoomed ? 1.5 : 1) | |
.animation(.interpolatingSpring(stiffness: 170, damping: 15), value: zoomed) | |
.onTapGesture(count: 2) { | |
// Switch from the start value to the end value and vice versa | |
zoomed.toggle() | |
} | |
} | |
} | |
struct ContentView_Previews: PreviewProvider { | |
static var previews: some View { | |
ContentView() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment