AJMessage
示例
要运行示例项目,首先克隆仓库,然后从 Example 目录先运行 pod install
。
要求
XCode 10.2
Swift 5
安装
AJMessage 可通过 CocoaPods 获得。要安装它,只需将以下行添加到您的 Podfile 中。
pod 'AJMessage'
更新日志
- 与初始视图分离的显示功能
AJMessage(title: title, message: msg).show()
//or
let asd = AJMessage(title: title, message: msg)
asd.show()
- 回调函数
onHide
已弃用并更改为onDismiss
,并具有AJMessage
类的值。 - 为每个状态添加了新的背景色配置
setBackgroundColor
- 为每个状态添加了新的图标配置
setImage
已使用
简单使用
AJMessage.show(title: "This is title", message: "message for description",position:.top).onHide {
print("did dissmiss")
}
支持使用 NSAttributeString
let title = NSAttributedString(string: "Title", attributes: [.font:UIFont.systemFont(ofSize: 15)])
let msg = NSMutableAttributedString(string: "aasdasd", attributes: [.font:UIFont.systemFont(ofSize: 14)])
let attach = NSTextAttachment()
attach.image = UIImage(named:"plus")
msg.append(NSAttributedString(attachment: attach))
msg.append(NSAttributedString(string: "asdasdasdasd asdasdasdasd asdasdasdasd asdasdasdasd asdasd"))
AJMessage.show(title: title, message: msg,position:.top).onHide {
print("did dissmiss")
}
自定义配置
特定视图的呈现
var config = AJMessageConfig()
/**
config.titleFont
config.setBackgroundColor(.cyan, status: .success)
config.setImage(UIImage(named:"warning"), status: .info)
*/
AJMessage.show(title: "This is title", message: "message for description", config: config)
全局视图的呈现只需在 didFinishLaunchingWithOptions
中设置 AJMessageConfig.shared
var config = AJMessageConfig.shared
/**
config.titleFont
config.setBackgroundColor(.cyan, status: .success)
config.setImage(UIImage(named:"warning"), status: .info)
*/
作者
ajijoyo, [email protected]
许可证
AJMessage 受 MIT 许可证许可。有关更多信息,请参阅 LICENSE 文件。