https://github.com/1691665955/mzlongpressbutton
兼容长按与点击事件、类似购物车加减按钮
https://github.com/1691665955/mzlongpressbutton
button ios longpress swift
Last synced: 3 months ago
JSON representation
兼容长按与点击事件、类似购物车加减按钮
- Host: GitHub
- URL: https://github.com/1691665955/mzlongpressbutton
- Owner: 1691665955
- License: mit
- Created: 2021-12-18T01:03:41.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-12-29T07:18:45.000Z (over 3 years ago)
- Last Synced: 2025-02-13T19:46:29.869Z (4 months ago)
- Topics: button, ios, longpress, swift
- Language: Swift
- Homepage:
- Size: 198 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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)
```