显示部分
func showToast(_ text: String) {
label.text = text
guard toast.alpha == 0 else {
return
}
toast.layer.masksToBounds = true
toast.layer.cornerRadius = 7.5
UIView.animate(withDuration: 0.25, animations: {
self.toast.alpha = 1
self.toast.frame = self.toast.frame.insetBy(dx: -5, dy: -5)
})
}
隐藏部分
func hideToast() {
UIView.animate(withDuration: 0.25, animations: {
self.toast.alpha = 0
self.toast.frame = self.toast.frame.insetBy(dx: 5, dy: 5)
})
}