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

首頁 > 系統 > iOS > 正文

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

2020-07-26 02:32:33
字體:
來源:轉載
供稿:網友

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

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彈框的字體顏色及字體的方法就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持武林網。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 南京市| 安徽省| 怀来县| 东丽区| 文水县| 区。| 莎车县| 蓬安县| 永善县| 新宾| 丹阳市| 西贡区| 琼海市| 威信县| 丽水市| 尉犁县| 城市| 清流县| 温州市| 济宁市| 凉城县| 手机| 桂平市| 鄂伦春自治旗| 图木舒克市| 富裕县| 潞西市| 沁源县| 农安县| 木兰县| 昭通市| 瑞安市| 沧源| 镇赉县| 安西县| 和静县| 湘阴县| 宜丰县| 广宁县| 射阳县| 宁晋县|