- 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'sholdButtonCompletion
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.
- Initialize the button
- Set the button's
holdButtonCompletion
property to tell the button what to do when it's done animating.
Example:
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)