您的位置:首页 > 移动开发 > Swift

苹果官方Toast Demo关键代码,Swift实现

2017-10-27 11:30 1081 查看
显示部分
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)
})
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: