iOS-YHAlertView(自定义AlertView,Swift版)

MYCSDN: samuelandkevin

github: YHAlertView

简单介绍

YHAlertView是仿系统的UIAlertView,UIAlertController弹出风格而定制的弹出视图。支持多选择,模糊背景,通俗易懂,扩展性好,代码无侵入。由此,你可以定制专属风格的AlertView.

API 介绍

在YHAlertView.swift文件中,用标注的方式Public Property,Public Method,Private Property,Private Method区分好公有和私有的属性、方法。

调用方式

可以参考我的DEMO.:YHAlertView

// 样式一:
// message 和 cancelBtn 为nil
    YHAlertView.show(title: "YHAlertView", message: nil, cancelButtonTitle: nil, otherButtonTitle: "确定") { 
    (alertV:YHAlertView, index:Int) in
             print("点击下标是:\(index)")
     }
                
// 样式二:
// message 好长
    YHAlertView.show(title: "YHAlertView", message: "消息好长啊啊啊消息好长啊啊啊消息好长啊啊啊消息好长啊啊啊消息好长啊啊啊消息好长啊啊啊消息好长啊啊啊消息好长啊啊啊消息好长啊啊啊消息好长啊啊啊消息好长啊啊啊消息好长啊啊啊消息好长啊啊啊消息好长啊啊啊消息好长啊啊啊消息好长啊啊啊消息好长啊啊啊消息好长啊啊啊消息好长啊啊啊消息好长啊啊啊消息好长啊啊啊消息好长啊啊啊消息好长啊啊啊消息好长啊啊啊消息好长啊啊啊消息好长啊啊啊消息好长啊啊啊消息好长啊啊啊消息好长啊啊啊消息好长啊啊啊消息好长啊啊啊消息好长啊啊啊消息好长啊啊啊消息好长啊啊啊消息好长啊啊啊消息好长啊啊啊消息好长啊啊啊消息好长啊啊啊消息好长啊啊啊消息好长啊啊啊消息好长啊啊啊消息好长啊啊啊消息好长啊啊啊消息好长啊啊啊消息好长啊啊啊消息好长啊啊啊消息好长啊啊啊消息好长啊啊啊消息好长啊啊啊消息好长啊啊啊消息好长啊啊", cancelButtonTitle: "取消", otherButtonTitle: "确定") {
    (alertV:YHAlertView, index:Int) in
             print("点击下标是:\(index)")
    }

// 样式三
// 多选择弹框
    YHAlertView.show(title: "YHAlertView", message: "多选择弹框", cancelButtonTitle: "取消", otherButtonTitles:"1","2","3","4","5","6"){     
    (alertV:YHAlertView, index:Int) in
              print("点击下标是:\(index)")
    }


// 样式四
// 取消模糊背景
    let alertV = YHAlertView(title: "YHAlertView", message: "取消模糊背景", delegate: self, cancelButtonTitle: "取消", otherButtonTitles: ["确定"])
    alertV.visual = false
    alertV.show()

// 样式五
// 取消弹出动画,改变背景颜色
    let alertV = YHAlertView(title: "YHAlertView", message: "取消弹出动画,改变背景颜色", delegate: self, cancelButtonTitle: "取消", otherButtonTitles: ["确定"])
    alertV.visual = false
    alertV.animationOption = .none
    alertV.visualBGColor = UIColor.red
    alertV.show()

效果图

1.message 和 cancelBtn 为nil

2.message 好长

3.多选择弹框
4.取消模糊背景
5.取消弹出动画,改变背景颜色

6.YHAlertView.gif

点赞的都是帅哥和美女!

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容