-
Notifications
You must be signed in to change notification settings - Fork 112
Click Event and Listener (Swift)
Weiping Huang edited this page May 13, 2017
·
4 revisions
Listener for clicking each button or animation-states. Check the demo for more details.
Swift | Objective-C
You can add a simple clicked-closure for each boom-button by adding listeners to each builder of them.
for _ in 0..<bmb.piecePlaceEnum.pieceNumber() {
let builder = SimpleCircleButtonBuilder.init()
// Event closure when the boom-button corresponding the builder itself is clicked.
builder.clickedClosure = { (index: Int) -> Void in
// the boom-button is clicked
}
bmb.addBuilder(builder)
}
If you want to manager all the click events in one method, you can use BoomDelegate:
...
bmb.boomDelegate = self
...
func boomMenuButton(_ bmb: BoomMenuButton, didClickBoomButtonOfBuilder builder: BoomButtonBuilder, at
index: Int) {
// If you have implement clickedClosures for boom-buttons in builders,
// then you shouldn't add any listener here for duplicate callbacks.
// buttonLabel.text = builder.normalImageName
}
func boomMenuButtonDidClickBackground(boomMenuButton bmb: BoomMenuButton) {
animationLabel.text = "Click background!!!"
}
func boomMenuButtonWillReboom(boomMenuButton bmb: BoomMenuButton) {
animationLabel.text = "Will RE-BOOM!!!";
}
func boomMenuButtonDidReboom(boomMenuButton bmb: BoomMenuButton) {
animationLabel.text = "Did RE-BOOM!!!"
}
func boomMenuButtonWillBoom(boomMenuButton bmb: BoomMenuButton) {
animationLabel.text = "Will BOOM!!!"
}
func boomMenuButtonDidBoom(boomMenuButton bmb: BoomMenuButton) {
animationLabel.text = "Did BOOM!!!"
}
Get the states of BMB by:
bmb.isAnimating() // Whether BMB is animating.
bmb.isBoomed() // Whether BMB is boomed.
bmb.isReBoomed() // Whether BMB is re-boomed.
Home
Chapters
- Basic Usage
- Simple Circle Button
- Text Inside Circle Button
- Text Outside Circle Button
- Ham Button
- Share Style
- Custom Position
- Button Place Alignments
- Different Ways to Boom
- Ease Animations for Buttons
- Different Order for Buttons
- Other Animations Attributes for Buttons
- Click Event and Listener
- Control BMB
- Use BMB in Navigation Bar
- Use BMB in Table View
- Attributes for BMB or Pieces on BMB
- Cache Optimization & Boom Area
- Change Boom Buttons Dynamically
- Blur Background & Tip
- Fade Views
- Structure of BMB
- Version History