iOS/Swift

[UIKit] κ°„λ‹¨ν•œ toast message, 확인 λ²„νŠΌλ§Œ μžˆλŠ” alert 예제

extension UIViewController {
    func alert(_ message: String, completion: (()->Void)? = nil) {
        DispatchQueue.main.async {
            let alert = UIAlertController(title: nil, message: message, preferredStyle: .alert)
            let okAction = UIAlertAction(title: "확인", style: .cancel) { (_) in
                completion?()
            }
            alert.addAction(okAction)
            self.present(alert, animated: false)
        }
    }
}

μ‚¬μš©ν•  λ•Œμ—λŠ” μ•„λ¬΄λ°μ„œλ‚˜

self.alert("μ•Œλ¦Όλ©”μ‹œμ§€!!!")

 μ΄λ ‡κ²Œ μ‚¬μš©ν•˜λ©΄ λœλ‹€ 😎

λ°˜μ‘ν˜•