XQSheet
从底部提供的便捷菜单。
开发这个控件的主要原因是因为系统的 UIActionSheet 在 iOS8 已经被废弃了,而 UIAlertController 在自定义颜色、字体方面不是很方便,而且 UIAlertController 需要 iOS8 及以上系统,考虑到还需要适配 iOS7,所以做了这样一个控件。通过工厂方法传入不同的参数可以实例化多种样式的菜单。
按钮的顺序与添加的顺序一致。
功能
自定义菜单上的文字颜色、文字字体大小等更加方便。采用 block 回调的方式配置按钮及执行按钮事件,使代码更加紧凑。适配 iPhoneX。
集成
pod 'XQSheet'
使用
//通过工厂方法实例化对象, XQSheetTypeSelect/XQSheetTypeAction两种
XQSheet *sheet = [XQSheet sheetWithType:XQSheetTypeSelect title:nil subTitle:nil cancelButtonTitle:nil];
sheet.selectedBtnMarkImage = [UIImage imageNamed:@"fb_btn_selected"];
[sheet addBtnWithTitle:@"先不冲" configHandler:nil actionHandler:^(UIButton *button, NSString *buttonTitle, NSInteger buttonIndex) {
UIAlertView *av = [[UIAlertView alloc] initWithTitle:@"提示" message:[NSString stringWithFormat:@"你选择了:%@", buttonTitle] delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil];
[av show];
}];
[sheet addBtnWithTitle:@"冲满" configHandler:nil actionHandler:^(UIButton *button, NSString *buttonTitle, NSInteger buttonIndex) {
UIAlertView *av = [[UIAlertView alloc] initWithTitle:@"提示" message:[NSString stringWithFormat:@"你选择了:%@", buttonTitle] delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil];
[av show];
}];
[sheet addBtnWithTitle:@"别烦我" configHandler:nil actionHandler:^(UIButton *button, NSString *buttonTitle, NSInteger buttonIndex) {
UIAlertView *av = [[UIAlertView alloc] initWithTitle:@"提示" message:[NSString stringWithFormat:@"你选择了:%@", buttonTitle] delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil];
[av show];
}];
sheet.selectedIndex = 1;
[sheet showSheetWithController:self completion:nil];
效果
样式1
样式2
样式3
样式4
样式5
注意事项
该控件暂不支持横屏。使用过程中有任何bug,可以告诉我。