美文网首页iOS开发攻城狮的集散地iOS技术
iOS 仿微信、微博底部弹出选项框

iOS 仿微信、微博底部弹出选项框

作者: 左左4143 | 来源:发表于2018-09-13 21:45 被阅读117次

由于项目中经常使用,封装了一个简单的底部弹出框控件,可以自定义一下属性,希望可以帮到需要的朋友。

GitHub地址

使用方法很简单,将文件夹导入工程中,并引入头文件#import "ZGQActionSheetView.h"

同时支持block与delegate两种回调方式,推荐使用block

block方式:

- (IBAction)ShowAction:(id)sender {
    NSArray *optionArray = @[@"发送给朋友",@"收藏",@"保存图片",@"编辑"];
    ZGQActionSheetView *sheetView = [[ZGQActionSheetView alloc] initWithOptions:optionArray completion:^(NSInteger index) {
        NSLog(@"%@",optionArray[index]);
    } cancel:^{
         NSLog(@"取消");
    }];
    [sheetView show];
}

delegate方式:

- (IBAction)ShowAction1:(UIButton *)sender {
    NSArray *optionArray = @[@"发送给朋友",@"收藏",@"保存图片",@"编辑"];
    optionArray = [NSArray array];
    ZGQActionSheetView *sheetView = [[ZGQActionSheetView alloc] initWithOptions:optionArray];
    sheetView.delegate = self;
    [sheetView show];

}

- (void)ZGQActionSheetView:(ZGQActionSheetView *)sheetView didSelectRowAtIndex:(NSInteger)index text:(NSString *)text {
    NSLog(@"%zd,%@",index,text);
}

sheetView 样式及属性可自定义,头文件中已给出详细注释

效果图:

image

相关文章

网友评论

    本文标题:iOS 仿微信、微博底部弹出选项框

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