SwiftUI 100 레시피/Gestures
-
SwiftUI Gestures - 3D 로테이션(회전)SwiftUI 100 레시피/Gestures 2022. 6. 20. 12:41
X, Y, Z 축 값을 변형하여 로테이션 효과를 준다 import SwiftUI struct ContentView: View { @State private var flipped: Bool = false var body: some View { VStack{ HStack{ }.frame(maxWidth: 300, maxHeight: 150) .background(LinearGradient(gradient: Gradient(colors:[Color.red, Color.blue]), startPoint: .leading, endPoint: .trailing)) .clipShape(RoundedRectangle(cornerRadius: 25.0, style: .continuous)) .rotation3DEffec..
-
SwiftUI Gestures - 이미지 드래그SwiftUI 100 레시피/Gestures 2022. 6. 20. 12:19
이미지를 드래그하고 화면의 특정지역으로 드래그 했을때 경고표시 나게 하는 방법 import SwiftUI struct ContentView: View { @State private var position = CGPoint(x: 100, y:100) let bounds = UIScreen.main.bounds @State private var danger : Bool = false var body: some View { VStack{ Image("Image") .resizable() .frame(maxWidth: 100, maxHeight: 100) .zIndex(1.0) .position(position) .gesture(DragGesture() .onChanged({(value) in position ..
-
SwiftUI Gestures - 이미지 회전SwiftUI 100 레시피/Gestures 2022. 6. 20. 11:55
import SwiftUI struct ContentView: View { @State private var degrees : Double = 0.0 var body: some View { VStack{ Image("Image") .resizable() .aspectRatio(contentMode: .fit) .rotationEffect(.degrees(degrees)) .padding(.top, 50) .animation(.default) Spacer() Button("회전"){ degrees += 90 } }.padding() } } struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView() ..
-
SwiftUI Gestures - 제스쳐, 그림 확대 및 축소하기SwiftUI 100 레시피/Gestures 2022. 6. 20. 11:40
import SwiftUI struct ContentView: View { @State private var currentScale: CGFloat = 1.0 @GestureState private var zoomFactor: CGFloat = 1.0 var magnification : some Gesture{ return MagnificationGesture() .updating($zoomFactor){(value, scale,transaction) in scale = value }.onEnded{(value) in currentScale *= value } } var body: some View { Image("Image") .resizable() .aspectRatio(contentMode: .fi..