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開(kāi)發(fā)中使用cocos2d添加觸摸事件的方法
這篇文章主要介紹了iOS開(kāi)發(fā)中使用cocos2d添加觸摸事件的方法,cocos2d是制作iOS游戲的利器,需要的朋友可以參考下2015-10-10
IOS開(kāi)發(fā)仿微信右側(cè)彈出視圖實(shí)現(xiàn)
這篇文章主要介紹了IOS開(kāi)發(fā)仿微信右側(cè)彈出視圖實(shí)現(xiàn)的相關(guān)資料,希望通過(guò)本文能幫助到大家,讓大家實(shí)現(xiàn)這樣類似的功能,需要的朋友可以參考下2017-10-10
移動(dòng)端固定輸入框在底部會(huì)被鍵盤遮擋的解決方法(必看篇)
下面小編就為大家分享關(guān)于移動(dòng)端固定輸入框在底部會(huì)被鍵盤遮擋的解決方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2017-12-12
iOS利用AFNetworking實(shí)現(xiàn)文件上傳的示例代碼
本篇文章主要介紹了iOS利用AFNetworking實(shí)現(xiàn)文件上傳的示例代碼,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2017-02-02
iOS實(shí)現(xiàn)手指點(diǎn)擊出現(xiàn)波紋的效果
最近在閑暇的時(shí)間做了一個(gè)反饋手指點(diǎn)擊屏幕的效果,用到了CAShapeLayer和基本的動(dòng)畫知識(shí),實(shí)現(xiàn)的效果很贊,這種效果使用在某些頁(yè)面上肯定會(huì)給用戶更有趣的體驗(yàn),特別是面向兒童的app中。文中給出了詳細(xì)的示例代碼,感興趣的朋友們下面來(lái)一起看看吧。2016-12-12
iOS 條碼及二維碼掃描(從相冊(cè)中讀取條形碼/二維碼)及掃碼過(guò)程中遇到的坑
本文主要給大家介紹ios中從手機(jī)相冊(cè)中讀取條形碼和二維碼的問(wèn)題及解決辦法,需要的朋友參考下2017-01-01

