-
Notifications
You must be signed in to change notification settings - Fork 112
Basic Usage (Swift)
How to use BMB in just several lines of code?
Swift | Objective-C
From version 2.0.0, BMB can be used directly in .storyboard or .xib. Add a view to view-controller and then change the Class
to BoomMenuButton
and change the Module
to VHBoomMenuButton
in identity inspector. Of course, BMB can be also added by frame-initialization method:
var bmb = BoomMenuButton.init(frame: CGRect.init(x: 0, y: 0, width: 60, height: 60))
And, don't forget to import BMB:
import VHBoomMenuButton
After adding a BMB in your view-controller, now you should tell BMB what kind of boom-buttons(the sub-buttons when booming) that you expect to boom by setting ButtonEnum property.
-
ButtonEnum.simpleCircle
corresponding to Simple Circle Button -
ButtonEnum.textInsideCircle
corresponding to Text Inside Circle Button -
ButtonEnum.textOutsideCircle
corresponding to Text Outside Circle Button -
ButtonEnum.ham
corresponding to Ham Button
bmb.buttonEnum = .simpleCircle
Then you need to tell BMB how it should place pieces on itself. Click the links for 4 kinds of buttons above to check different piece-place-enums.
bmb.piecePlaceEnum = .dot_3_1
Now tell BMB how to place the buttons on the screen when booming. Click the links for 4 kinds of buttons above to check different button-place-enums.
bmb.buttonPlaceEnum = .sc_3_3
You have set enough properties for BMB itself, now add builders for customizing boom-buttons to BMB. There are 4 different builders for the 4 kinds of boom-buttons above. For instance, use SimpleCircleButtonBuilder for ButtonEnum.simpleCircle
. Click the links for 4 kinds of buttons above to find out how to use builders.
for _ in 0..<bmb.piecePlaceEnum.pieceNumber() {
let builder = SimpleCircleButtonBuilder.init()
builder.normalImageName = "PictureName"
bmb.addBuilder(builder)
}
And now your BMB is ready for a boom.
You must keep the number of piece-place-enum, number of button-place-enum and number of builders being the same.
The name of piece-place-enum is xxx_n_m
, where xxx
is name(dot
or ham
), n
is number and m
represents different types. Similarly, the name of button-place-enum is yyy_n_m
. You must keep the first n
equals to the second one. But you needn't keep the two m
same(The code above is an example: dot_3_1
and sc_3_3
). Unless the piece-place-enum is share
or custom
. Check Share Style and Custom Position for more details.
And the number of builders must be n
. Any breaking-rules-code will get an assert.
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