Skip to content

ray1942/RAlertView

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 

Repository files navigation

RAlertView

RAlertView --- 弹窗 前几天写了菊花,后来发现还缺个弹窗,于是乎写了简单的弹窗。到目前为止,项目中遇到的弹窗还没有要求说有输入框的,所以写了个简简单单的弹窗。相关说明也同步到简书了 http://www.jianshu.com/p/590882ccac8d 显示效果和部分代码学习了https://github.com/mrchenhao/HHAlertView,感谢作者

显示效果有多种:成功(默认)/错误/警告/详情/自定义图标

  • 成功(默认)

成功

  • 错误

错误

  • 警告

警告

  • 详情

详情提示

#使用方法 *使用初始化方法

//默认显示
RAlertView.init(title: String, detailText: String, cancelTitle: String)

//如果修改显示样式
RAlertView.init(title: String, detailText: String, cancelTitle: String, style: RAlertStyle)

//如果需要完成后处理点事情
RAlertView.init(title: String, detailText: String, cancelTitle: String, style: RAlertStyle, completClosure: (()->())?)

//如果需要添加多个按钮 需要设置delegate
 RAlertView.init(title: String, detailText: String, cancelTitle: String, style: RAlertStyle, delegate: RAlertViewDelegate?, otherTitles: Array<String>?, completClosure: (() -> ())?)

  • 显示样式
//弹窗样式
enum RAlertStyle: Int {
    case Success,Error,Warning,Info,Custom,Default;
}
  • 设置滑入屏幕的模式
//滑入样式
enum RAlertModel: Int{
    case Fade,Top,Bottom,Left,Right;
}

alert.enterModel = .Left
alert.leavaModel = .Right
  • 显示
alert.show()
  • 多个按钮时实现代理方法
extension XXViewController: RAlertViewDelegate{
    func alertView(alertView: RAlertView, didClickIndex: Int) {
        print(didClickIndex)
    }
}

封装完这个弹窗用Instruments测试了下Demo发现有内存泄漏问题,经过研究添加了alertDestroy方式来完成弹窗的扫尾工作。

About

RAlertView --- 弹窗

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages