Gestures:SwiftUI 扩展手势 API
Gestures 是一个轻量级、开源的 SwiftUI 手势 API 扩展,消除了 iOS 16 和 macOS 13 之前的限制 - 不能定位手势。
如何使用
此代码块演示了如何使用 Gestures 库与 SwiftUI 配合使用
Rectangle()
.onTouchGesture(count: 1) { gesture in
print(gesture.location)
}
.onSwipeGesture(minimumDistance: 15.0, coordinateSpace: .local) { direction, location in
print(direction, location)
} onEnded: { direction, location in
print(direction, location)
}
有关更多用法示例,请参阅 示例应用。
入门:安装
Swift Package Manager
要使用Swift Package Manager安装Gestures库,请将以下行添加到您的Package.swift
文件中的依赖数组中:
.package(url: "https://github.com/vospennikov/Gestures.git", .upToNextMinor(from: "1.0.6"))
Cocoapods
或者,您可以使用CocoaPods安装Gestures。将以下行添加到您的Podfile文件中:
pod 'SUIGestures', '1.0.6'
Documentation
发布版和main
的文档在此处可用
License
Gestures库在MIT授权许可下可用。更多信息请参阅LICENSE文件。