如何在UIAlertController

时间:2015-06-01 05:27:37

标签: swift uialertcontroller

我想将UIAlertController中“取消”按钮的颜色更改为橙​​色,并保持“注销”按钮的颜色不变。我已经在下面附上了屏幕截图和警报控制器的代码。

enter image description here

警报视图的代码

alert = UIAlertController(title: "", message: "Are you sure you want to log out?", preferredStyle: UIAlertControllerStyle.Alert)
    alert.view.tintColor = UIColor.blackColor()
    alert.addAction(UIAlertAction(title: "Log out", style: UIAlertActionStyle.Cancel, handler:{ (UIAlertAction)in

        println("Log Out button clicked.")

        prefs.setBool(false, forKey: "Isloggedin")
        NSUserDefaults.resetStandardUserDefaults()
        prefs.setBool(true, forKey: "IsEmail")
        prefs.setObject(email, forKey: "loggedemail")
        prefs.synchronize()
        let mainview = self.storyboard?.instantiateViewControllerWithIdentifier("mainscreen") as! mainViewController

        self.navigationController?.pushViewController(mainview, animated: true)
    }))

    //alert.view.tintColor = UIColor.yellowColor()
    alert.addAction(UIAlertAction(title: "Cancel", style: UIAlertActionStyle.Default, handler:{ (UIAlertAction)in
        println("Cancel button clicked.")
    }))

    self.presentViewController(alert, animated: true, completion: {
        println("completion block.")


    })

0 个答案:

没有答案