-1
我嘗試創建動態警報通知,我想使用自定義的方法在一類這樣的(SETERROR:紅色背景,setSuccess:綠色背景,...):迅速動態UIAlertController
AlertHelpers.SetError("Error Password", viewController: self)
這是我的代碼,我不知道它的好辦法:
class AlertHelpers {
func notificationAlert(message:String, viewController : UIViewController) {
//Create alert Controller _> title, message, style
let alertController = UIAlertController(title: "Error", message: message, preferredStyle: UIAlertControllerStyle.Alert)
//Create button Action -> title, style, action
let successAction = UIAlertAction(title: "OK", style: UIAlertActionStyle.Default) {
UIAlertAction in
NSLog("OK Pressed")
}
alertController.addAction(successAction)
viewController.presentViewController(alertController, animated: true, completion:nil)
}
}
class SetError : AlertHelpers {
override func notificationAlert(message:String, viewController : UIViewController) {}
alertController.view.backgroundColor = .redColor() //RED BACKGROUND
}
alertController不承認,我無法找到解決通過的消息,查看通過SETERROR。
我從POO開始我不明白我如何創建從全局類繼承但可定製的子類。如果有人能解釋我的好方法...