An open API service indexing awesome lists of open source software.

https://github.com/1691665955/mzlongpressbutton

兼容长按与点击事件、类似购物车加减按钮
https://github.com/1691665955/mzlongpressbutton

button ios longpress swift

Last synced: 3 months ago
JSON representation

兼容长按与点击事件、类似购物车加减按钮

Awesome Lists containing this project

README

        

# MZLongPressButton
MZLongPressButton是兼容长按与点击事件、类似购物车加减按钮的控件



#### Cocoapods 引入
```
pod 'MZLongPressButton', '~> 0.0.1'
```

#### 使用
```
let minusBtn = MZLongPressButton(type: .custom)
minusBtn.frame = CGRect(x: 40, y: 100, width: 80, height: 40)
minusBtn.setTitle("-", for: .normal)
minusBtn.setTitleColor(.brown, for: .normal)
// 触发长按时间需要长按的时间
btn.timeStart = 0.3
// 出发长按事件后每隔多长时间执行longPress回调
btn.timeGap = 0.1
// 点击或长按事件回调
minusBtn.longPress = {
// 长按连续触发
print("我被点击了")
}
self.view.addSubview(minusBtn)
```