3 回答
TA貢獻1841條經驗 獲得超3個贊
UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"Dont care what goes here, since we're about to change below" messa
ge:@"" preferredStyle:UIAlertControllerStyleActionSheet];NSMutableAttributedString *hogan = [[NSMutableAttributedString alloc] initWithString
:@"Presenting the great... Hulk Hogan!"];[hogan addAttribute:NSFontAttributeName
value:[UIFont systemFontOfSize:50.0]
range:NSMakeRange(24, 11)];[alertVC setValue:hogan forKey:@"attributedTitle"];UIAlertAction *button = [UIAlertAction
actionWithTitle:@"Label text"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *action){
//add code to make something happen once tapped}];UIImage
*accessoryImage = [UIImage imageNamed:@"someImage"];
[button setValue:accessoryImage forKey:@"image"];let alert = UIAlertController(title: nil, message: nil, preferredStyle: .ActionSheet)let action = UIAlertAction(title: "Some title", style:
.Default, handler: nil)let attributedText = NSMutableAttributedString(string: "Some title")let range = NSRange(location: 0, length: attrib
utedText.length)attributedText.addAttribute(NSKernAttributeName, value: 1.5, range: range)attributedText.addAttribute(NSFontAttributeName,
value: UIFont(name: "ProximaNova-Semibold", size: 20.0)!, range: range)alert.addAction(action)presentViewController(alert, animated: true, c
ompletion: nil)// this has to be set after presenting the alert, otherwise the internal property __representer is nilguard let label = act
ion.valueForKey("__representer")?.valueForKey("label") as? UILabel else { return }label.attributedText = attributedTextguard let label = (action!.value(forKey: "__representer")as? NSObject)?.value(forKey: "label") as? UILabel else { return }
label.attributedText = attributedTextTA貢獻1111條經驗 獲得超0個贊
// In your AppDelegate for example:
window?.tintColor = UIColor.redColor()
// Elsewhere in the App:
let alertVC = UIAlertController(title: "Title", message: "message", preferredStyle: .Alert)
alertVC.addAction(UIAlertAction(title: "Cancel", style: .Cancel, handler: nil))
alertVC.addAction(UIAlertAction(title: "Ok", style: .Default, handler: nil))
// Works on iOS 8, but not on iOS 9
// On iOS 9 the button color will be red
alertVC.view.tintColor = UIColor.greenColor()
self.presentViewController(alert, animated: true, completion: nil)
// Necessary to apply tint on iOS 9
alertVC.view.tintColor = UIColor.greenColor()
- 3 回答
- 0 關注
- 4201 瀏覽
添加回答
舉報
