RBMenu 0.2.5

RBMenu 0.2.5

测试已测试
Lang语言 Obj-CObjective C
许可证 MIT
Released最后发布2015年5月

你的名字 维护。



RBMenu 0.2.5

  • Roshan Balaji

一款灵感来自 Medium iOS 应用 的 iOS 菜单

Output gif Output gif2

安装

首选的安装方法是使用 CocoaPods。将此行添加到 podfile

pod 'RBMenu',  '~>0.2.4'

如果你想手动安装,将 RBMenu 的 .h 和 .m 文件复制到项目目录。

使用方法

RBMenu 由 RBMenuItems 表示的菜单项组成。目前每个项包含标题和完成处理函数。要创建一个菜单项

#import "RBMenu.h"

通过创建 RBMenuItems 类的对象来创建每个菜单项。对于此演示项目,菜单项由以下片段创建。每个元素都有当用户点击选项时执行的处理函数。

RBMenuItem *item = [[RBMenuItem alloc]initMenuItemWithTitle:@"First" withCompletionHandler:^(BOOL finished){

   NSLog(@"First selected");

}];
RBMenuItem *item2 = [[RBMenuItem alloc]initMenuItemWithTitle:@"Second" withCompletionHandler:^(BOOL finished){

    NSLog(@"Second selected");

}];

一旦创建了项,就有必要将它们添加到 RBMenu 中。代理需要是 UIViewController 的子类

 _menu = [[RBMenu alloc] initWithItems:@[item, item2] andTextAlignment:RBMenuTextAlignmentLeft forViewController:self];

在上述代码中,RBMenuItems 被添加到菜单中,并在创建菜单时也指定了标题在菜单中的对齐方式。可以通过以下方法对自定义属性进行自定义菜单。

-(RBMenu *)initWithItems:(NSArray *)menuItems
           textColor:(UIColor *)textColor
 hightLightTextColor:(UIColor *)hightLightTextColor
     backgroundColor:(UIColor *)backGroundColor
   andTextAlignment:(RBMenuAlignment)titleAlignment
   forViewController:(UIViewController *)viewController

目前 RBMenu 支持 three 种菜单标题对齐方式

RBMenuTextAlignmentLeft
RBMenuTextAlignmentRight
RBMenuTextAlignmentCenter

附加的演示项目会提供更多信息。

自定义

可以自定义以下菜单属性

@property(nonatomic)CGFloat          height;
@property(nonatomic, strong)UIColor *textColor;
@property(nonatomic, strong)UIFont  *titleFont;
@property(nonatomic, strong)UIColor *highLightTextColor;
@property(nonatomic)RBMenuAlignment titleAlignment;

截图

screenshot

待办事项

  1. 菜单中添加图像
  2. 注释代码 :(
  3. 添加横屏支持

许可证

RBMenu 在 MIT 许可证 (MIT) 下可用

版权所有 © 2014 Roshan Balaji

以下条件下,无论是对个人还是团体,都可以免费获得本软件及其相关文档文件的副本(以下称为“软件”)(以下称为“软件”)的使用、复制、修改、合并、发布、分发、再许可和/或出售副本,并允许提供软件的个人或团体进行如下操作

必须包含上述版权声明和本许可声明在软件的每一份副本或实质性部分中。

本软件提供“现状保证”,不提供任何形式的担保,包括但不限于适销性、特定用途适用性和非侵权性的保证。在任何情况下,作者或版权所有者不对任何索赔、损害或其他责任负责,无论是在合同、侵权或其他法律行为中产生、源自或将软件或软件的使用或其他行为与之关联。