import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
self.view.backgroundColor = UIColor.orange
yeToastView() // 各种 形式的 提示 弹窗:
}
// 各种 形式的 提示 弹窗:
func yeToastView(){
// .show()方法 显示 弹窗:
// 1. Delay.long: 3.5秒, Delay.short:2秒;
//Toast(text: "Hello, CoolKeTang!").show()
//Toast(text: "自定义显示的时长", duration: 1.5).show() //自定义显示的时长;
//Toast(text: "Hello, CoolKeTang!", duration: Delay.long).show()
//Toast(text: "延时2s显示", delay: Delay.short, duration: Delay.long).show()
// 2.
// let toast = Toast(text: "Hello")
// toast.show()
// toast.cancel() // 关闭弹窗:
// 3. Toast管理中心 , 获得当前的Toast窗口:
// if let currentToast = ToastCenter.default.currentToast
// {
// currentToast.cancel()
// }
// 关闭所有的弹窗:
//ToastCenter.default.cancelAll()
// 4. 自定义样式:
ToastView.appearance().backgroundColor = .orange
ToastView.appearance().textColor = UIColor.blue
ToastView.appearance().font = UIFont(name: "Arial", size: 18)
ToastView.appearance().textInsets = UIEdgeInsets(top: 16, left: 20, bottom: 16, right: 20)
ToastView.appearance().cornerRadius = 0 //圆角半径;
//竖屏时 Toast 窗口到屏幕底部的距离: 100
ToastView.appearance().bottomOffsetPortrait = 100
Toast(text: "Since Toaster 2.0.0, you can use UIAppearance to set default appearance. This is an short example to set default background color to orange!").show()
}
}