美文网首页
iOS实现类似微信alertView

iOS实现类似微信alertView

作者: L小杰 | 来源:发表于2016-06-30 14:27 被阅读268次
    支持Block和Delegate的方式回调点击位置。
    • 具体使用方法:Block
      1. 导入头文件 #import "XJActionSheet.h"
      2. 创建XJActionSheet XJActionSheet *actionSheet = [XJActionSheet actionSheetWithTitle:<#(NSString *)#> confirms:<#(NSArray *)> cancel:<#(NSString *)#> style:<#(XJActionSheetStyle)#> click:^(NSInteger index) { <#code#> }];
      3. 展示到window上 [actionSheet showInView:self.view.window];
    • 具体使用方法:Delegate
      1. 导入头文件 #import "XJActionSheet.h"
      2. 加入协议 <XJActionSheetDelegate>
      3. 创建XJActionSheet并设置代理为self XJActionSheet *actionSheet = [XJActionSheet actionSheetWithTitle:<#(NSString *)#> confirms:<#(NSArray *)#> cancel:<#(NSString *)#> style:<#(XJActionSheetStyle)#>]; actionSheet.delegate = self; [actionSheet showInView:self.view.window];
      4. #pragma mark - XJActionSheetDelegate
        - (void)clickAction:(XJActionSheet *)actionSheet atIndex:(NSUInteger)index { NSLog(@"选中了 %ld",index); }
        实现选中的事件
    完整的项目代码:github链接
    效果: 效果图

    相关文章

      网友评论

          本文标题:iOS实现类似微信alertView

          本文链接:https://www.haomeiwen.com/subject/aetfjttx.html