VHBoomMenuButton是一个瞬间爆炸效果的菜单按钮组件。
使用示例:
下面一个非常简单的例子,如何构建拥有三个圆形按钮的BMB:
//// ViewController.m// VHBoomMenuButtonTest//// Created by 黄伟平 on 16/8/7.// Copyright © 2016年 黄伟平. All rights reserved.//#import "ViewController.h"#import "VHBoomMenuButton.h"#define UIColorFromRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16)) / 255.0 green:((float)((rgbValue & 0xFF00) >> 8)) / 255.0 blue:((float)(rgbValue & 0xFF)) / 255.0 alpha:1.0]@interface ViewController ()@end@implementation ViewController- (void)loadView{ CGRect screenFrame = [[UIScreen mainScreen] bounds]; self.view = [[UIView alloc] initWithFrame:screenFrame]; self.view.backgroundColor = [UIColor whiteColor]; self.view.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth; // 1. 把BMB放在你想放的地方 CGFloat bmbRadius = 60; VHBoomMenuButton *bmb = [[VHBoomMenuButton alloc] initWithFrame:CGRectMake(screenFrame.size.width - 20 - bmbRadius, screenFrame.size.height - 20 - bmbRadius, bmbRadius, bmbRadius)]; // 2. 选择你想要的按钮类型 bmb.buttonEnum = VHButtonSimpleCircle; // 3. 在爆炸之前,告诉BMB你想怎么放在它身上 bmb.piecePlaceEnum = VHPiecePlace_DOT_3_1; // 4. 在爆炸之后,告诉BMB你想怎么放在屏幕上 bmb.buttonPlaceEnum = VHButtonPlace_SC_3_3; // 5. 添加按钮 [bmb addSimpleCircleButtonBuilderBlock:^(VHSimpleCircleButtonBuilder *builder) { builder.imageNormal = @"bat"; builder.buttonNormalColor = UIColorFromRGB(0xD32F2F); builder.buttonPressedColor = UIColorFromRGB(0xF44336); }]; [bmb addSimpleCircleButtonBuilderBlock:^(VHSimpleCircleButtonBuilder *builder) { builder.imageNormal = @"bear"; builder.buttonNormalColor = UIColorFromRGB(0xD32F2F); builder.buttonPressedColor = UIColorFromRGB(0xF44336); }]; [bmb addSimpleCircleButtonBuilderBlock:^(VHSimpleCircleButtonBuilder *builder) { builder.imageNormal = @"bee"; builder.buttonNormalColor = UIColorFromRGB(0xD32F2F); builder.buttonPressedColor = UIColorFromRGB(0xF44336); }]; [self.view addSubview:bmb];}@end你所需要做的只是选择属性,其他由BMB完成。
警告!你必须保证piecePlaceEnum的数量,buttonPlaceEnum的数量,你添加的builders数量一致。可以注意到,piecePlaceEnum的名字是VHPiecePlace_XXX_N_M,XXX是名字,N表示按钮数量,M用作表示不同种类。类似的,buttonPlaceEnum的名字是VHButtonPlace_YYY_N_M。你必须保证两者的N相同,当然M可以不通,比如例子中的:VHPiecePlace_DOT_3_1和VHButtonPlace_SC_3_3。
评论