2017-07-11 90 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)