RotationGesture 旋转手势 (SwiftUI 中文文档手册)
程序员文章站
2024-03-24 14:52:28
...
RotationGesture 旋转手势
识别旋转运动并跟踪旋转角度的手势。
struct RotationGesture
总览
旋转手势跟踪旋转事件序列的变化方式。要识别视图上的旋转手势,请创建并配置该手势,然后使用修饰符将其添加到视图中。gesture(_:including:)
将旋转手势添加到Rectangle并应用旋转效果:
struct RotationGestureView: View {
@State var angle = Angle(degrees: 0.0)
var rotation: some Gesture {
RotationGesture()
.onChanged { angle in
self.angle = angle
}
}
var body: some View {
Rectangle()
.frame(width: 200, height: 200, alignment: .center)
.rotationEffect(self.angle)
.gesture(rotation)
}
}
加入我们一起学习SwiftUI
QQ:3365059189
SwiftUI技术交流QQ群:518696470
推荐阅读
-
RotationGesture 旋转手势 (SwiftUI 中文文档手册)
-
CGImageSourceCreateWithData (SwiftUI UIKit中文文档手册)
-
NSHostingController (SwiftUI中文文档手册)
-
UIViewRepresentable (SwiftUI UIKit中文文档手册)
-
sheet(isPresented:onDismiss:content:) (SwiftUI 中文文档手册 教程含源码)
-
MKCoordinateSpan 缩放层级 MapKit (SwiftUI 中文手册文档)
-
MKPointAnnotation MapKit(SwiftUI UIKit中文文档手册)
-
UIToolbar UIKit(SwiftUI中文文档手册)
-
barTintColor (SwiftUI UIKit中文文档手册)
-
UISearchBar UIKit (SwiftUI UIKit中文文档手册)