https://github.com/amirdaliri/amholderbutton
For an example of creating a AMHoldButton in storyboard, check out the example project.
https://github.com/amirdaliri/amholderbutton
custombutton holderbutton programatically storyboard uibutton
Last synced: 23 days ago
JSON representation
For an example of creating a AMHoldButton in storyboard, check out the example project.
- Host: GitHub
- URL: https://github.com/amirdaliri/amholderbutton
- Owner: AmirDaliri
- License: mit
- Created: 2017-12-13T10:22:51.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-01-03T09:39:44.000Z (over 7 years ago)
- Last Synced: 2025-03-23T20:23:59.699Z (about 1 month ago)
- Topics: custombutton, holderbutton, programatically, storyboard, uibutton
- Language: Swift
- Homepage:
- Size: 23.4 KB
- Stars: 6
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# AMHolderButton swift 4, iOS 11

### Storyboard
- Drag a UIButton onto your view.
- Change it's class to `AMHolderButton`
- Edit it's appearance using the custom properties in the Attributes Inspector
- Create the button as a property of it's View Controller
- In the `viewDidLoad()` method of your View Controller, set the button's `holdButtonCompletion` property to tell the button what to do when it's done animating.For an example of creating a AMHoldButton in storyboard, check out the example project.
### Programatically
- Initialize the button
- Set the button's `holdButtonCompletion` property to tell the button what to do when it's done animating.Example:
```swift 4
let bttn = AMHoldButton(frame: CGRect(x: 0, y: 0 , width: 200, height: 50), slideColor: UIColor.green, slideTextColor: UIColor.white, slideDuration: 1.0)
bttn.backgroundColor = UIColor.clear
bttn.setText("👍🏻")
bttn.setTextFont(UIFont.boldSystemFont(ofSize: 18))
bttn.textColor = UIColor.green
bttn.holdButtonCompletion = {() -> Void in
print("Hold button has completed!")
}
bttn.resetDuration = 0.2
bttn.borderWidth = 3.0
bttn.borderColor = UIColor.green
bttn.cornerRadius = bttn.frame.width / 2
self.view.addSubview(bttn)
```