CocoaPods trunk is moving to be read-only. Read more on the blog, there are 19 months to go.
TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | Jun 2015 |
Maintained by HistoryZhang.
模仿微信的ActionSheet.支持修改文字颜色,支持多行.
使用cocoapods
Podfile
中添加pod 'HZActionSheet'
.pod update
.Masonry
,所以最终下载的源码也包括Masonry
.关于Masonry
,大家可自行google
.不使用cocoapods
HZActionSheet
.Masonry
.添加代码
创建HZActionSheet
HZActionSheet *sheet = [[HZActionSheet alloc] initWithTitle:@"选择照片" delegate:self cancelButtonTitle:@"取消" destructiveButtonIndexSet:nil otherButtonTitles:@[@"相册", @"相机"]];
destructiveButton
传递的是一个IndexSet
.
显示HZActionSheet
[sheet showInView:self.view];
HZActionSheet
是添加到view
的window
上的,所以不需要传递view.window
属性.
点击按钮在delegate
中处理
- (void)actionSheet:(HZActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (actionSheet.cancelButtonIndex != buttonIndex) {
NSLog(@"你点击了 %@", @(buttonIndex));
}
}
给按钮设置其他颜色
sheet.titleColor = [UIColor purpleColor];