一套友好的、方便集成的底部item选择视图,性能优秀,集成简单,对原有代码风格不产生任何影响!
- 直接把LNActionSheet.h 和 LNActionSheet.m 拖到工程中使用
- 使用Cocoapods: pod "LNAlertSheetView"
- 改成单利实现,性能更优秀
- 多种显示样式可供选择
- 多样化的事件处理方式
- 使用极其简单,一行代码全部搞定
- UI的显示分为有没有头部描述、有没有子标题
- 事件的处理分为在LNActionSheetModel内部处理 和 在显示的回调中处理,根据个人的使用习惯而定,没有什么区别
更快、更简洁
目前没发现问题
LNActionSheet
- 只需要引入LNActionSheet类,调用+ (void)showWithDesc:(NSString*)desc actionModels:(NSArray<LNActionSheetModel*> *)mdoels action:(void(^)(LNActionSheetModel *model))action; 美好的事情立刻发生
-如果需要改变现实的外观,请直接修改头文件中的宏
#define BG_Color [UIColor colorWithRed:0 green:0 blue:0 alpha:0.6]
#define Bottom_BG_Color [UIColor colorWithHexString:@"EFEFEF"]
#define Desc_Color [UIColor colorWithHexString:@"#666666"]
#define Desc_Font [UIFont systemFontOfSize:12]
#define Item_Normal_Color [UIColor blackColor]
#define Item_Normal_Font [UIFont systemFontOfSize:16]
#define Sub_Item_Normal_Color [UIColor blackColor]
#define Sub_Item_Normal_Font [UIFont systemFontOfSize:12]
#define Item_Delete_Color [UIColor redColor]
#define Item_Delete_Font [UIFont systemFontOfSize:13]
首先创建需要操作的item对应的model
NSMutableArray *array = [NSMutableArray new];
NSArray *titles = @[@"加好友",@"加关注",@"收藏",@"举报",@"删除"];
NSArray *subTitles = @[@"找也找也找朋友,找到一个好朋友",
@"加关注是成为好友的第一步",
@"喜欢的话就保存起来吧",
@"涉黄、赌博、消沉的可以举报,帮我们净化环境",
@"要慎重哦,删了就全没了"];
for (int i = 0; i < titles.count; i++) {
LNActionSheetModel *model = [[LNActionSheetModel alloc]init];
model.title = titles[i];
model.subTitle = subTitles[i];
model.sheetId = i;
model.itemType = LNActionSheetItemNoraml;
if (i == titles.count-1) {
model.itemType = LNActionSheetItemDelete;
}
[array addObject:model];
}
其中model中用到一个枚举,从来表明对应的item的类型
/**
item的类型
- LNActionSheetItemNoraml: 默认都是普通类型的
*/
typedef NS_OPTIONS(NSUInteger,LNActionSheetItemType){
LNActionSheetItemNoraml = 0, //普通
LNActionSheetItemDelete, //删除
LNActionSheetItemSure, //确定
};
然后创建并显示
[LNActionSheet showWithDesc:@"有标题和子标题的sheet" actionModels:[NSArray arrayWithArray:array] action:^(LNActionSheetModel *model) {
}];