2017-07-11 44 views
0

我在我的项目中有alertalert就像其他警报一样简单。我想改变font style and color。这怎么可能?Swift 3 - alert style

在此先感谢!

回答

0
let attributedString = NSAttributedString(string: "YourTitle", attributes: [ 
    NSFontAttributeName : UIFont.systemFontOfSize(18), //your font here 
    NSForegroundColorAttributeName : UIColor.black() 
]) 
let alert = UIAlertController(title: "TextTitle", message: "YourMessage", preferredStyle: .Alert) 

alert.setValue(attributedString, forKey: "attributedTitle") 
let cancelAction = UIAlertAction(title: "Cancel", 
style: .Default) { (action: UIAlertAction!) -> Void in 
} 

presentViewController(alert, 
animated: true, 
completion: nil)