iOS 修改alertViewController彈框的字體顏色及字體的方法
系統(tǒng)默認(rèn)的字體是黑色,按鈕顏色是藍(lán)色或者紅色的,我們?cè)鯓幼远x字體呢
Codeing Show
UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"提示" message:@"確認(rèn)退出登錄?" preferredStyle:(UIAlertControllerStyleAlert)];
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
NSLog(@"點(diǎn)擊了Cancel");
[alertVC dismissViewControllerAnimated:YES completion:nil];
}];
UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"確定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
NSLog(@"點(diǎn)擊了OK");
[[NSUserDefaults standardUserDefaults] setObject:nil forKey:kLoginUserKey];
[alertVC dismissViewControllerAnimated:YES completion:nil];
}];
//修改title
NSMutableAttributedString *alertControllerStr = [[NSMutableAttributedString alloc] initWithString:@"提示"];
[alertControllerStr addAttribute:NSForegroundColorAttributeName value:kMainTextColor range:NSMakeRange(0, 2)];
[alertControllerStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:15] range:NSMakeRange(0, 2)];
[alertVC setValue:alertControllerStr forKey:@"attributedTitle"];
//修改message
NSMutableAttributedString *alertControllerMessageStr = [[NSMutableAttributedString alloc] initWithString:@"確認(rèn)退出登錄?"];
[alertControllerMessageStr addAttribute:NSForegroundColorAttributeName value:kSubTextColor range:NSRangeFromString(@"確認(rèn)退出登錄?")];
[alertControllerMessageStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:13] range:NSRangeFromString(@"確認(rèn)退出登錄?")];
[alertVC setValue:alertControllerMessageStr forKey:@"attributedMessage"];
//修改按鈕字體顏色
[cancelAction setValue:kGreenColor forKey:@"titleTextColor"];
[okAction setValue:kGreenColor forKey:@"titleTextColor"];
[alertVC addAction:cancelAction];
[alertVC addAction:okAction];
[self presentViewController:alertVC animated:YES completion:nil];
這里的kGreenColor 等是我自定義的顏色,換成自己的字體顏色即可
以上這篇iOS 修改alertViewController彈框的字體顏色及字體的方法就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
相關(guān)文章
ios NSNotificationCenter通知的簡(jiǎn)單使用
這篇文章主要介紹了ios NSNotificationCenter通知的簡(jiǎn)單使用,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2018-06-06
iOS runtime動(dòng)態(tài)添加方法示例詳解
Runtime是想要做好iOS開發(fā),或者說是真正的深刻的掌握OC這門語言所必需理解的東西。下面這篇文章主要給大家介紹了關(guān)于iOS runtime動(dòng)態(tài)添加方法的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),需要的朋友可以參考下。2018-01-01
iOS tableView實(shí)現(xiàn)頭部拉伸并改變導(dǎo)航條漸變色
這篇文章主要為大家詳細(xì)介紹了iOS tableView實(shí)現(xiàn)頭部拉伸并改變導(dǎo)航條漸變色,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-05-05
cmake ios終端下執(zhí)行提示錯(cuò)誤 iOS version not found, tested: [5.0;5.1;6
這篇文章主要介紹了cmake ios終端下執(zhí)行提示錯(cuò)誤 iOS version not found, tested: [5.0;5.1;6.0;6.1;7.0;8.3]的解決方案的相關(guān)資料,需要的朋友可以參考下2016-10-10
iOS開發(fā)之UITableView左滑刪除等自定義功能
今天來給大家介紹下iOS開發(fā)中UITableView左滑實(shí)現(xiàn)微信中置頂,刪除等功能。對(duì)大家開發(fā)iOS具有一定的參考借鑒價(jià)值,有需要的朋友們一起來看看吧。2016-09-09

