Things take time

[SWIFT] Toast Message 만들기 본문

iOS (기능)

[SWIFT] Toast Message 만들기

겸손할 겸 2017. 11. 22. 17:18

[코드]


바로 코드로 넘어간다.

     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)
        })