国产探花免费观看_亚洲丰满少妇自慰呻吟_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開發頻道。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 彭州市| 澎湖县| 扶风县| 剑川县| 桐梓县| 江永县| 靖安县| 伽师县| 沁水县| 郴州市| 石屏县| 玛纳斯县| 宜阳县| 思茅市| 昌宁县| 桑日县| 宁波市| 新晃| 巴塘县| 汝南县| 七台河市| 松江区| 文成县| 秭归县| 瑞安市| 攀枝花市| 平遥县| 萝北县| 淮阳县| 蕉岭县| 冀州市| 瓮安县| 伊宁市| 张家川| 察隅县| 宝应县| 都江堰市| 府谷县| 北流市| 巩留县| 蒙城县|