iOS如何修改alertViewController弹框的字体颜色及字-创新互联

这篇文章主要介绍了iOS如何修改alertViewController弹框的字体颜色及字,具有一定借鉴价值,感兴趣的朋友可以参考下,希望大家阅读完这篇文章之后大有收获,下面让小编带着大家一起了解一下。

创新互联服务项目包括博望网站建设、博望网站制作、博望网页制作以及博望网络营销策划等。多年来,我们专注于互联网行业,利用自身积累的技术优势、行业经验、深度合作伙伴关系等,向广大中小型企业、政府机构等提供互联网行业的解决方案,博望网站推广取得了明显的社会效益与经济效益。目前,我们服务的客户以成都为中心已经辐射到博望省份的部分城市,未来相信会继续扩大服务区域并继续获得客户的支持与信任!

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弹框的字体颜色及字”这篇文章对大家有帮助,同时也希望大家多多支持创新互联建站,关注创新互联网站建设公司行业资讯频道,更多相关知识等着你来学习!

另外有需要云服务器可以了解下创新互联建站www.cdcxhl.com,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。

当前名称:iOS如何修改alertViewController弹框的字体颜色及字-创新互联
标题路径:https://www.cdcxhl.com/article46/ceejeg.html

成都网站建设公司_创新互联,为您提供App设计网站内链商城网站Google云服务器网站建设

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联

h5响应式网站建设