UIAlertController custom font, size, color

后端 未结 25 1980
遥遥无期
遥遥无期 2020-11-22 09:06

I am using new UIAlertController for showing alerts. I have this code:

// nil titles break alert interface on iOS 8.0, so we\'ll be using empty strings
UIAle         


        
25条回答
  •  孤城傲影
    2020-11-22 09:58

    To change the color of one button like CANCEL to the red color you can use this style property called UIAlertActionStyle.destructive :

    let prompt = UIAlertController.init(title: "Reset Password", message: "Enter Your E-mail :", preferredStyle: .alert)
            let okAction = UIAlertAction.init(title: "Submit", style: .default) { (action) in
                  //your code
    }
    
    let cancelAction = UIAlertAction.init(title: "Cancel", style: UIAlertActionStyle.destructive) { (action) in
                    //your code
            }
            prompt.addTextField(configurationHandler: nil)
            prompt.addAction(okAction)
            prompt.addAction(cancelAction)
            present(prompt, animated: true, completion: nil);
    

提交回复
热议问题