ZBCustomSheet 自定义带透明背景层的SheetView

31 篇文章 0 订阅

ZBAlertView.h 、ZBCustomSheet、ZBShareSheetView

自定义AlertView、SheetView:点击透明背景层隐藏视图,根据需求自己定制View,
项目中经常用到自定义到弹出视图,自定义Alert样式、自定义Sheet,点击背景层隐藏视图。

1. 导入头文件:

#import "ZBAlertView.h"
#import "ZBCustomSheet.h"
#import "ZBShareSheetView.h"

2. 添加代码

alert弹窗

- (IBAction)alertBtnAction:(UIButton *)sender {
    NSArray *titleArray = @[@"按钮0",@"按钮1",@"按钮2",@"按钮3"];
    [ZBAlertView showAlertWithTitle:@"付款完成前请不要关闭此窗口,完成付款后请根据您的实际情况点击此按钮" message:nil verticalButtonTitles:titleArray selectedBlock:^(NSInteger index) {
        NSLog(@"点击了%ld",index);
        [sender setTitle:titleArray[index] forState:UIControlStateNormal];
    }];
}

sheet弹窗:

//选择性别
- (IBAction)sheetBtnAction:(UIButton *)sender {
    [ZBCustomSheet showSheetViewWithSex:self.sex SelectedBlock:^(NSInteger index) {
        NSLog(@"------> index: %ld", index);
        self.sex = index;
        NSString *title = @"选择性别";
        if (index == 1) {
            title = @"男";
        }else if (index == 2){
            title = @"女";
        }
        [sender setTitle:title forState:UIControlStateNormal];
    }];
}

//分享
- (IBAction)sheetShareAction:(UIButton *)sender {
    [ZBShareSheetView showSheetViewComplete:^(int clickType) {
        NSLog(@"点击了:%d",clickType);
    }];
}

3. 展示效果:

效果预览.gif

就这么简单就完成了。我这里只展示了一个选择性别的简单视图,提供一种实现方式,有需要的朋友可以根据产品需求修改UI样式实现自己想要的UI。
欢迎有更好实现方式的朋友一起交流,互相学习🙏




GitHub:https://github.com/biyuhuaping/ZBAlertSheetView
CSDN:https://blog.csdn.net/biyuhuaping/article/details/93492001

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值