简单的 Swift 移动端 toast 通知
显示默认 toast 通知的函数
QToasterSwift.toast(target: UIViewController, text: String, title: String?, iconURL: String?, iconPlaceHolder: UIImage?, backgroundColor: UIColor?, textColor: UIColor?, onTouch: () -> Void)
所有可选参数都可以删除
显示(不含标题及其他参数)带有信息的 toaster
QToasterSwift.toast(self, text: "Welcome to QToasterSwift")
显示(只含信息及标题)的 toaster
QToasterSwift.toast(self, text: "Welcome to QToasterSwift", title: "Welcome")
显示含 UIImage 图标或 URL 图标(连同 placeholder 图标)的 toaster
let image = UIImage(named:"my-image")
QToasterSwift.toastWithIcon(self, text: "Welcome to QToasterSwift", icon: image, title: "Welcome")
let placeholderImage = UIImage(named: "placeholder-image")
let iconUrl = "https://my-icon-url/icon.jpg"
QToasterSwift.toast(self,
text: "Welcome to QToasterSwift",
title: "Welcome",
iconURL: iconUrl,
iconPlaceHolder: placeholderImage)
更复杂的带 onTouch 动作的基本 toaster
let placeholderImage = UIImage(named: "placeholder-image")
let iconUrl = "https://my-icon-url/icon.jpg"
QToasterSwift.toast(self,
text: "Welcome to QToasterSwift sample usage code",
title: "Welcome",
iconURL: iconUrl,
iconPlaceHolder: placeholderImage,
backgroundColor: UIColor.redColor(),
textColor: UIColor.whiteColor(),
onTouch: {
print("toaster touched")
}
)
QToasterSwift 还支持更多可配置的风格参数。
let placeholderImage = UIImage(named: "placeholder-image")
let iconUrl = "https://my-icon-url/icon.jpg"
let toaster = QToasterSwift()
toaster.textAlignment = NSTextAlignment.Center
toaster.textFont = UIFont.systemFontOfSize(11.0)
toaster.titleFont = UIFont.systemFontOfSize(11.0, weight: 0.8)
toaster.titleText = "Welcome"
toaster.text = "Welcome to QToasterSwift sample usage code"
toaster.iconImage = placeholderImage
toaster.iconURL = iconUrl
toaster.backgroundColor = UIColor.blueColor()
toaster.textColor: UIColor = UIColor.whiteColor()
toaster.animateDuration = 0.1
toaster.delayDuration = 3.0
toaster.iconSquareSize = 30.0
toaster.iconCornerRadius = 5.0
toaster.iconBackgroundColor = UIColor.blackColor()
toaster.toast(self) // self is your view controller
toaster.toast(self, onTouch: {
print("toaster touched")
})
请通过您的贡献和/或为我们加星标来跟踪此仓库的任何更新。谢谢。