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

ZBCustomSheet

项目中经常用到自定义到弹出视图,有的类似于Alert,有的从底部往上弹,类似与Sheet,今天,就一起分享一下带有带透明背景层的SheetView,点击背景层隐藏视图。

1. 导入头文件:

#import "ZBCustomSheet.h"

2. 添加代码:

- (IBAction)buttonClicked:(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];
    }];
}

3. 展示效果:

CustomSheet.gif

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




gitHub: [https://github.com/biyuhuaping/ZBCustomSheet.git)
简书:https://www.jianshu.com/p/8e2c6a0f2772

猜你喜欢

转载自blog.csdn.net/biyuhuaping/article/details/93491998