Mobile App/iOS와 Swift
iOS Toast 메세지 만들기 (2)
IKKIson
2019. 4. 16. 16:42
func showToast() {
let toastLabel = UILabel(frame: CGRect(x: view.frame.size.width/2 - 150, y: view.frame.size.height-100, width: 300, height : 35))
toastLabel.backgroundColor = UIColor.clear
toastLabel.textColor = UIColor.black
toastLabel.textAlignment = NSTextAlignment.center;
view.addSubview(toastLabel)
toastLabel.text = "토스트 메세지 입니다."
toastLabel.font = UIFont.boldSystemFont(ofSize: 18)
toastLabel.alpha = 1.0
toastLabel.layer.cornerRadius = 10;
toastLabel.clipsToBounds = true
UIView.animate(withDuration: 1.0, animations: {
toastLabel.alpha = 0.0
}, completion: {
(isBool) -> Void in
self.dismiss(animated: true, completion: nil)
})
}