Skip to content

Instantly share code, notes, and snippets.

@amosgyamfi
Last active August 27, 2021 06:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amosgyamfi/c99f7ff83bb1cb5266192b1e33f0fb1a to your computer and use it in GitHub Desktop.
Save amosgyamfi/c99f7ff83bb1cb5266192b1e33f0fb1a to your computer and use it in GitHub Desktop.
//
// 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