CocoaPods trunk is moving to be read-only. Read more on the blog, there are 19 months to go.

HZActionSheet 1.0.1

HZActionSheet 1.0.1

TestsTested
LangLanguage Obj-CObjective C
License MIT
ReleasedLast Release Jun 2015

Maintained by HistoryZhang.



  • By
  • HistoryZhang

模仿微信的ActionSheet.支持修改文字颜色,支持多行.

效果图

image

使用方法

  • 使用cocoapods

    1. Podfile中添加pod 'HZActionSheet'.
    2. 运行pod update.
    3. 由于我使用了第三方库Masonry,所以最终下载的源码也包括Masonry.关于Masonry,大家可自行google.
  • 不使用cocoapods

    1. 下载代码之后,添加文件夹HZActionSheet.
    2. 你还需要下载另一个三方库Masonry.
  • 添加代码

    创建HZActionSheet

    HZActionSheet *sheet = [[HZActionSheet alloc] initWithTitle:@"选择照片" delegate:self cancelButtonTitle:@"取消" destructiveButtonIndexSet:nil otherButtonTitles:@[@"相册", @"相机"]];
    

    destructiveButton传递的是一个IndexSet.

    显示HZActionSheet

    [sheet showInView:self.view];
    

    HZActionSheet是添加到viewwindow上的,所以不需要传递view.window属性.

    点击按钮在delegate中处理

    - (void)actionSheet:(HZActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
    {
        if (actionSheet.cancelButtonIndex != buttonIndex) {
            NSLog(@"你点击了 %@", @(buttonIndex));
        }
    }
    

    给按钮设置其他颜色

    sheet.titleColor = [UIColor purpleColor];