-
Notifications
You must be signed in to change notification settings - Fork 112
Basic Usage (Objective C)
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 VHBoomMenuButton
in identity inspector. Of course, BMB can be also added by frame-initialization method:
VHBoomMenuButton *bmb = [[VHBoomMenuButton alloc] initWithFrame:CGRectMake(0, 0, 60, 60)];
And, don't forget to import BMB:
#import <VHBoomMenuButton/VHBoomMenuButton.h>
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 VHButtonEnum property.
-
VHButtonSimpleCircle
corresponding to Simple Circle Button -
VHButtonTextInsideCircle
corresponding to Text Inside Circle Button -
VHButtonTextOutsideCircle
corresponding to Text Outside Circle Button -
VHButtonHam
corresponding to Ham Button
bmb.buttonEnum = VHButtonSimpleCircle;
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 = VHPiecePlaceDOT_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 = VHButtonPlaceSC_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 VHButtonSimpleCircle
. Click the links for 4 kinds of buttons above to find out how to use builders.
for (int i = 0; i < bmb.pieceNumber; i++)
{
VHSimpleCircleButtonBuilder *builder = [VHSimpleCircleButtonBuilder builder];
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: VHPiecePlaceDOT_3_1
and VHButtonPlaceSC_3_3
). Unless the piece-place-enum is VHPiecePlaceShare
or VHPiecePlaceCustom
. 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