国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統 > iOS > 正文

iOS 修改alertViewController彈框的字體顏色及字體的方法

2019-10-21 18:42:20
字體:
來源:轉載
供稿:網友

系統默認的字體是黑色,按鈕顏色是藍色或者紅色的,我們怎樣自定義字體呢

Codeing Show

UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"提示" message:@"確認退出登錄?" preferredStyle:(UIAlertControllerStyleAlert)]; UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) { NSLog(@"點擊了Cancel"); [alertVC dismissViewControllerAnimated:YES completion:nil]; }]; UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"確定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { NSLog(@"點擊了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:@"確認退出登錄?"]; [alertControllerMessageStr addAttribute:NSForegroundColorAttributeName value:kSubTextColor range:NSRangeFromString(@"確認退出登錄?")]; [alertControllerMessageStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:13] range:NSRangeFromString(@"確認退出登錄?")]; [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彈框的字體顏色及字體的方法就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持VEVB武林網。


注:相關教程知識閱讀請移步到IOS開發頻道。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 中方县| 陆良县| 衡山县| 江华| 鹤庆县| 鄄城县| 蒲城县| 科技| 嘉义市| 曲水县| 吴江市| 安平县| 岢岚县| 共和县| 苍梧县| 铜川市| 丹巴县| 镇江市| 湘潭县| 西和县| 北宁市| 郁南县| 甘泉县| 湘阴县| 邯郸县| 克东县| 如皋市| 社会| 庆云县| 伽师县| 肇东市| 广丰县| 江城| 吉木萨尔县| 墨脱县| 霍城县| 温州市| 元谋县| 泌阳县| 鹤岗市| 陇西县|