PanGestureView 允许您在用户拖动视图时附加自定义操作。想象一下它是一个可滑动 UITableViewCell,但作为通用的 UIView。
使用 Cocoapods 安装: pod 'PanGestureView', '~> 0.1'
将 PanGestureView 的一个实例添加为任何视图的子视图。您需要的其他任何子视图都可以添加到 PanGestureView 的 contentView
中。
动作可以添加如下
let action = PanGestureAction(swipeDirection: PanGestureViewSwipeDirection.Right, image: UIImage(named: ...)!)
// BG color of the actionView
action.backgroundColor = UIColor(...)
// Tint color of the provided UIImage. Images are automatically converted to their template versions using `imageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate)`
action.tintColor = UIColor(...)
// Trigger handling
action.didTriggerBlock = {
direction in
// Handle action
}
panGestureView.addAction(action)
每个滑动方向支持一个动作。
PanGestureView 在 MIT 许可证下可用。