MLMenu
示例
要运行示例项目,请先克隆仓库,然后从 Example 目录中运行 pod install
预览
需求!
iOS 8.0
安装
MLMenu 通过 CocoaPods 提供。要安装它,只需将以下行添加到您的 Podfile 中
pod 'MLMenu'
使用
// 导入头文件
#import <MLMenu/MLMenuView.h>
- (void)testCode_One
{
NSArray *titles = @[@"发起群聊",@"添加朋友",@"扫一扫",@"收付款"];
MLMenuView *menuView = [[MLMenuView alloc] initWithFrame:CGRectMake([UIScreen mainScreen].bounds.size.width - 100 - 10, 0, 100, 44 * 4) WithTitles:titles WithImageNames:nil WithMenuViewOffsetTop:k_StatusBarAndNavigationBarHeight WithTriangleOffsetLeft:80 triangleColor:[UIColor whiteColor]];
menuView.separatorOffSet = 10;
menuView.separatorColor = MLClolor(51, 51, 51, 1);
[menuView setMenuViewBackgroundColor:[UIColor whiteColor]];
menuView.titleColor = [UIColor blackColor];
[menuView setCoverViewBackgroundColor:MLClolor(51, 51, 51, 0.5)];
menuView.didSelectBlock = ^(NSInteger index) {
NSLog(@"%zd",index);
};
[menuView showMenuEnterAnimation:MLEnterAnimationStyleNone];
}
- (void)testCode_Two
{
NSArray *titles = @[@"发起群聊",@"添加朋友",@"扫一扫",@"收付款"];
NSArray *images = @[@"scan",@"scan",@"scan",@"scan"];
MLMenuView *menuView = [[MLMenuView alloc] initWithFrame:CGRectMake([UIScreen mainScreen].bounds.size.width - 100 - 10, 0, 100, 44 * 4) WithTitles:titles WithImageNames:images WithMenuViewOffsetTop:k_StatusBarAndNavigationBarHeight WithTriangleOffsetLeft:80 triangleColor:nil];
menuView.didSelectBlock = ^(NSInteger index) {
NSLog(@"%zd",index);
};
[menuView showMenuEnterAnimation:MLEnterAnimationStyleNone];
}
- (void)testCode_Three
{
NSArray *titles = @[@"发起群聊",@"添加朋友",@"扫一扫",@"收付款"];
NSArray *images = @[@"scan",@"scan",@"scan",@"scan"];
MLMenuView *menuView = [[MLMenuView alloc] initWithFrame:CGRectMake([UIScreen mainScreen].bounds.size.width - 100 - 10, 0, 100, 44 * 4) WithTitles:titles WithImageNames:images WithMenuViewOffsetTop:k_StatusBarAndNavigationBarHeight WithTriangleOffsetLeft:80 triangleColor:nil];
menuView.didSelectBlock = ^(NSInteger index) {
NSLog(@"%zd",index);
};
[menuView showMenuEnterAnimation:MLEnterAnimationStyleRight];
}
- (void)testCode_Four
{
NSArray *titles = @[@"发起群聊",@"添加朋友",@"扫一扫",@"收付款"];
NSArray *images = @[@"scan",@"scan",@"scan",@"scan"];
MLMenuView *menuView = [[MLMenuView alloc] initWithFrame:CGRectMake([UIScreen mainScreen].bounds.size.width - 100 - 10, 0, 100, 44 * 4) WithTitles:titles WithImageNames:images WithMenuViewOffsetTop:k_StatusBarAndNavigationBarHeight];
[menuView setCoverViewBackgroundColor:[UIColor lightGrayColor]];
menuView.didSelectBlock = ^(NSInteger index) {
NSLog(@"%zd",index);
};
[menuView showMenuEnterAnimation:MLEnterAnimationStyleTop];
}
- (void)testCode_Five
{
NSArray *titles = @[@"发起群聊",@"添加朋友",@"扫一扫",@"收付款"];
MLMenuView *menuView = [[MLMenuView alloc] initWithFrame:CGRectMake([UIScreen mainScreen].bounds.size.width - 100 - 10, 0, 100, 44 * 4) WithTitles:titles WithImageNames:nil WithMenuViewOffsetTop:k_StatusBarAndNavigationBarHeight WithTriangleOffsetLeft:80 triangleColor:[UIColor whiteColor]];
[menuView setCoverViewBackgroundColor:MLClolor(51, 51, 51, 0.5)];
menuView.separatorColor = MLClolor(51, 51, 51, 0.5);
[menuView setMenuViewBackgroundColor:[UIColor whiteColor]];
menuView.titleColor = MLClolor(51, 51, 51, 1);
menuView.didSelectBlock = ^(NSInteger index) {
NSLog(@"%zd",index);
};
[menuView showMenuEnterAnimation:MLEnterAnimationStyleNone];
}
其他用途
// 设置线条颜色(线条可调整透明度)
menuView.separatorColor = [UIColor ...];
// 设置字体大小
menuView.font = [UIFont systemFontOfSize:...];
// 设置字体颜色
menuView.titleColor = [UIColor ...];
// 设置背景颜色
[menuView setMenuViewBackgroundColor:...];
// 设置蒙版背景颜色
[menuView setCoverViewBackgroundColor:..];
作者
MrDML, [邮箱地址保护]
许可证
MLMenu遵循MIT许可证。有关更多信息,请参阅LICENSE文件。