https://github.com/inderdhir/holdtoclickbutton
A SwiftUI view that triggers a click after holding it for a set amount of time
https://github.com/inderdhir/holdtoclickbutton
button click hold ios ios-lib spm swift swift-package-manager
Last synced: 7 months ago
JSON representation
A SwiftUI view that triggers a click after holding it for a set amount of time
- Host: GitHub
- URL: https://github.com/inderdhir/holdtoclickbutton
- Owner: inderdhir
- License: mit
- Created: 2018-12-06T19:12:19.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2023-11-20T18:47:05.000Z (almost 2 years ago)
- Last Synced: 2025-01-24T15:09:02.542Z (8 months ago)
- Topics: button, click, hold, ios, ios-lib, spm, swift, swift-package-manager
- Language: Swift
- Homepage:
- Size: 280 KB
- Stars: 2
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# HoldToClickButton
A SwiftUI view that triggers a click after holding it for a set amount of time





## Example
```swift
HoldToClickButton(
label: {
Text("Hold To Click")
.fontWeight(.bold)
.foregroundColor(.black)
},
onHoldEnd: {
// Do something when clicked
}
)
```The following optional parameters are available
```swift
HoldToClickButton(
fillColor: Color = Color.orange,
borderColor: Color = Color.black,
borderWidth: CGFloat = 2.0,
holdDuration: TimeInterval = 1.5,
cancelDuration: TimeInterval = 0.3,
label: @escaping () -> Label,
onHoldBegin: (() -> Void)? = nil,
onHoldEnd: (() -> Void)? = nil,
onHoldCancel: (() -> Void)? = nil
)
```## Requirements
- Swift >= 5.7
- iOS >= 14
- macOS >= 13
- watchOS >= 7## Installation
### Swift Package Manager
HoldToClickButton is available as a Swift package.
### Manual
Include `HoldToClickButton.swift` in your project
## License
HoldToClickButton is available under the MIT license. See `LICENSE` for more info.