AEAlertView
AEAlertView不依赖于任何第三方库
Swift | 范围 | 使用 |
---|---|---|
版本 | 4.0及以下 | Pod 'AEAlertView','1.0' |
版本 | 4.0-5.0 | Pod 'AEAlertView','1.7' |
版本 | 5.0+ | Pod 'AEAlertView' |
请在使用前阅读说明。
如果您有任何问题,请在任何时间发送电子邮件或提交问题。非常感谢。
建议首先下载AlertViewDemo,并检查具体的用法。
版本2.3已更新
2.3更新
可以使用多行文本作为按钮文本,可以设置图片,并且可以左右排列图片(提示:如果未设置按钮高度,则将根据文本的最大高度统一使用)
弃用alertView上的之前按钮属性设置,请直接使用`AEAlertAction`进行按钮属性。
如果不需要在UIWindow上显示,请添加'public func create() {}',在配置后可以调用'create()'将alert添加到您需要添加的视图中。
`AEAlertAction`目前仅支持2种显示模式`defaulted,cancel`。
所有设置属性都在action中完成。如果您不想使用cancel,可以将所有操作都设置为defaulted。
v2.3.2- Support setting the maximum width
v2.3.4- Fix the problem that the title does not wrap lines by default. The number of Title lines can be set use.
感谢大家反馈,如果您在使用过程中遇到任何问题、bug、建议等,请提交点击进入讨论区
感谢您的反馈。如果在使用过程中遇到任何问题、bug、建议等,请随时提交它们讨论
预览
2.3
2.2
2.1
[email protected] -
如果有,您有任何问题或者好的建议,欢迎联系我 - 邮箱:简单使用
func test() {
AEAlertView.show(title: "title", message: "fastest", actions: ["ok"]) { action in
print("dismiss----Fastest")
}
// set background image
AEAlertView.show(title: "title", message: "set background image", actions: ["cancel", "ok"], bgImage: UIImage(named: "006")) { action in
print("dismiss----background")
}
}
添加到自定义的视图上
func test() {
let alert = AEAlertView.init(style: .defaulted, title: "title", message: "set gif height Add alert to the current view")
alert.setBackgroundImage(contentsOf: Bundle.main.path(forResource: "003", ofType: "gif"))
alert.backgroundImageHeight = 300
alert.messageColor = UIColor.red
let cancel = AEAlertAction.init(title: "cancel", style: .cancel) { (action) in
print("\(action.tag)")
alert.dismiss()
}
cancel.cancelTitleColor = .red
alert.addAction(action: cancel)
alert.create()
self.view.addSubview(alert)
}
自定义按钮主题
func test() {
let alert = AEAlertView(style: .defaulted, title: "custom action", message: "Please check the default values before using")
let cancel = AEAlertAction.init(title: "cancel\rcancel\rcancel", style: .cancel) { (action) in
alert.dismiss()
}
cancel.cancelTitleColor = UIColor.red
cancel.numberOfLines = 0
let dev = AEAlertAction.init(title: "dev", style: .defaulted) { (action) in
}
dev.image = UIImage(named: "index_def_icon")
// dev.imagePlacement = .right
alert.addAction(action: cancel)
alert.addAction(action: dev)
alert.show()
}
设置最大宽度
private func alertType3() {
let alert = AEAlertView.init(style: .defaulted, title: "title", message: "set gif height Add alert to the current view", maximumWidth: 600)
alert.setBackgroundImage(contentsOf: Bundle.main.path(forResource: "003", ofType: "gif"))
alert.backgroundImageHeight = 300
alert.messageColor = UIColor.red
let cancel = AEAlertAction.init(title: "cancel", style: .cancel) { (action) in
print("\(action.tag)")
alert.dismiss()
}
cancel.cancelTitleColor = .red
alert.addAction(action: cancel)
alert.create()
view.addSubview(alert)
}
*** 控件支持设置左右、上下间距。本来想提供类方法来一句话调用,但是每个项目的主题色不同,所以需要你自己设置自己的主题色 ***