TBSwiftExtensions 是一个令人愉快的 iOS,OSX 和 tvOS 库。
该库的目的是提供有用的扩展/辅助工具,可以在任何地方快速轻松地使用,以减少相同任务所使用的代码。
将 TBSwiftExtensions 文件夹复制到您的 Xcode 项目中。(确保将文件添加到您的目标)
您可以使用 Swift Package Manager 通过向您的 Package.swift
文件添加适当的描述来安装 TBSwiftExtensions
import PackageDescription
let package = Package(
dependencies: [
.Package(url: "https://github.com/tbaranes/TBSwiftExtensions.git", majorVersion: 0.1.3)
]
)
在此存储库中,您将找到使用库中的每个扩展/辅助工具进行 iOS,OSX 和 tvOS 的示例。
BlockTapGesturesRecognizers:
let blockTapGesture = BlockTapGestureRecognizer() { _ in
print("tap gesture detected")
}
view.addGestureRecognizer(blockTapGesture)
// OR
let blockTapGesture = BlockTapGestureRecognizer(numberOfTapsRequired: 1, numberOfTouchesRequired: 1) { _ in
print("tap gesture detected")
}
view.addGestureRecognizer(blockTapGesture)
BlockLongPressGesturesRecognizers:
let longPressGesture = BlockLongPressGestureRecognizer() { _ in
print("long press gesture detected")
}
view.addGestureRecognizer(longPressGesture)
// OR
let longPressGesture = BlockLongPressGestureRecognizer(numberOfTapsRequired: 0, numberOfTouchesRequired: 1, minimumPressDuration: 0.5) { _ in
print("long press gesture detected")
}
view.addGestureRecognizer(longPressGesture)
BlockSwipeGesturesRecognizers:
let swipeDownGesture = BlockSwipeGestureRecognizer(direction: .Down) { _ in
print("swipe gesture detected")
}
view.addGestureRecognizer(swipeDownGesture)
// OR
let swipeDownGesture = BlockSwipeGestureRecognizer(numberOfTouchesRequired: 1, direction: .Down) { _ in
print("swipe gesture detected")
}
view.addGestureRecognizer(swipeDownGesture)
BlockPanGesturesRecognizers:
let panGesture = BlockPanGestureRecognizer() { _ in
print("pan gesture detected"
}
view.addGestureRecognizer(panGesture)
// OR
let panGesture = BlockPanGestureRecognizer(minimumNumberOfTouches: 1) { _ in
print("pan gesture detected"
}
view.addGestureRecognizer(panGesture)
BlockPinchGesturesRecognizers:
let pinchGesture = BlockPinchGestureRecognizer { _ in
print("pinch gesture detected"
}
viewPinchGesture.addGestureRecognizer(pinchGesture)
TBSwiftExtensions 基于 MIT 协议。有关更多信息,请参阅LICENSE 文件。