【发布时间】:2018-04-03 10:28:10
【问题描述】:
我在导航栏中有一个 UIBarButton,点击后退按钮(第一次点击)我需要显示 toast(如警告),双击我需要快速退出页面,
以下用于显示 toast 的代码,其工作正常,
let toastLabel = UILabel(frame: CGRect(x: 20, y: self.view.frame.size.height-100, width: 350, height: 35))
toastLabel.backgroundColor = UIColor.black.withAlphaComponent(0.6)
toastLabel.textColor = UIColor.white
toastLabel.textAlignment = .center;
toastLabel.font = UIFont(name: "Montserrat-Light", size: 12.0)
toastLabel.text = "demo"
toastLabel.alpha = 1.0
toastLabel.layer.cornerRadius = 10;
toastLabel.clipsToBounds = true
self.view.addSubview(toastLabel)
UIView.animate(withDuration: 2.0, delay: 0.1, options: .curveEaseOut, animations: {
toastLabel.alpha = 0.0
}, completion: {(isCompleted) in
toastLabel.removeFromSuperview()
})
请指导我完成这项任务。
【问题讨论】:
标签: ios swift3 navigationbar