KxMenu.zip 第三方<头上添加 #import <UIKit/UIKit.h> >
气泡第三方测试.zip 例子
接入代码
#import "KxMenu.h" //引入头文件
@implementation ViewController {
BOOL _bShowMenu; //判断是否显示
int _bSelectedMenuID; //判断点击第几行
}
_bShowMenu = NO; //写默认初始化
_bSelectedMenuID = 3;
- (IBAction)showMenu:(UIButton *)sender {
if (_bShowMenu == YES) {
[KxMenu dismissMenu];
_bShowMenu = NO;
}
NSArray *menuItems =
@[
[KxMenuItem menuItem:@"规则详情"
image:nil
target:self
action:@selector(rulesDetailsButtonClick:)
idx:0],
[KxMenuItem menuItem:@"分享"
image:nil
target:self
action:@selector(shareButtonClick:)
idx:1],
];
#pragma mark 气泡上button点击时的颜色变化
CGFloat normalColor = 180.0f;
CGFloat selectedColor = 255.0f;
KxMenuItem *item;
CGFloat color;
for (int i = 0; i < menuItems.count; i++) {
color = normalColor;
if (_bSelectedMenuID == i) {
color = selectedColor;
}
item = menuItems[i];
#pragma mark 这个是字体颜色
item.foreColor = [UIColor colorWithRed:color/255.0f green:color/255.0f blue:color/255.0f alpha:1.0];
item.foreColor = [UIColor blackColor];
item.alignment = NSTextAlignmentLeft;
}
/**
很有意思的设定,改变x在一定范围内只有上面的下角标会动,下面部分不动
*/
CGFloat rectX = GETWIDTH(self.view) - 40;
CGFloat rectY = -40;
CGFloat rectW = 40;
CGFloat rectH = 40;
#pragma mark 气泡背景位置
CGRect rect = CGRectMake(rectX, rectY, rectW, rectH);
#pragma mark 渲染色
// [KxMenu setTintColor:[UIColor redColor]];
[KxMenu showMenuInView:self.view
fromRect:rect
menuItems:menuItems];
_bShowMenu = YES;
}
- (void)rulesDetailsButtonClick:(UIButton *)sender {
NSLog(@"规则详情");
}
- (void)shareButtonClick:(UIButton *)sender {
NSLog(@"分享");
}