【文件属性】:
文件名称:类似微信中的ActionSheet
文件大小:160KB
文件格式:ZIP
更新时间:2021-04-04 18:22:00
IOS源码
源码HZActionSheet,使用cocoapods,运行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));
}
}
给按钮设置其他颜色
【文件预览】:
HZActionSheet-master
----HZActionSheet()
--------main.m(337B)
--------HZActionSheet()
--------AppDelegate.h(280B)
--------AppDelegate.m(2KB)
--------Base.lproj()
--------.DS_Store(6KB)
--------ViewController.h(218B)
--------Images.xcassets()
--------Info.plist(1KB)
--------ViewController.m(2KB)
----screenshot.gif(210KB)
----Podfile(36B)
----HZActionSheet.xcodeproj()
--------project.xcworkspace()
--------project.pbxproj(20KB)
----LICENSE(1KB)
----.DS_Store(6KB)
----Podfile.lock(141B)
----.gitignore(493B)
----HZActionSheet.podspec(529B)
----HZActionSheet.xcworkspace()
--------contents.xcworkspacedata(231B)
----README.md(1KB)
----HZActionSheetTests()
--------Info.plist(750B)
--------HZActionSheetTests.m(880B)