UIAlertController 修改文字显示

swift开发笔记11 - 使用UIAlertController在底部弹出日期选择框 使用UIAlertController在底部弹出日期选择框UIDatePicker,并在UIAlertController的确定按钮中处理选中的日期。 阅读详情

UIAlertController修改文字显示

不废话先上完整代码
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"提示" message:@"提示内容" preferredStyle:UIAlertControllerStyleAlert];
    //修改标题
    NSMutableAttributedString *attrTitle = [[NSMutableAttributedString alloc] initWithString:@"提示"];
    [attrTitle addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:20] range:NSMakeRange(0, [[attrTitle string] length])];
    [attrTitle addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(0, [[attrTitle string] length])];
    [alertController setValue: attrTitle forKey:@"attributedTitle"];
    //修改message
    NSMutableAttributedString * attrMessage = [[NSMutableAttributedString alloc] initWithString:@"提示内容"];
    [attrMessage addAttribute:NSForegroundColorAttributeName value:[UIColor greenColor] range:NSMakeRange(0, [[attrMessage string] length])];
    [attrMessage addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:15] range:NSMakeRange(0, [[attrMessage string] length])];
    [alertController setValue: attrMessage forKey:@"attributedMessage"];
    //修改按钮的颜色,同上可以使用同样的方法修改内容,样式
    UIAlertAction *defaultAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:nil];
    UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil];
    [defaultAction setValue:[UIColor orangeColor] forKey:@"_titleTextColor"];
    [cancelAction setValue:[UIColor blueColor] forKey:@"_titleTextColor"];

    [alertController addAction:defaultAction];
    [alertController addAction:cancelAction];
    [self presentViewController:alertController animated:YES completion:nil];

修改标题属性

key: attributedTitle

//修改标题的内容,字号,颜色。使用的key值是“attributedTitle"
    NSMutableAttributedString *attr = [[NSMutableAttributedString alloc] initWithString:@"标题"];
    [attr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:50] range:NSMakeRange(0, [[attr string] length])];
    [attr addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(0, [[hogan string] length])];
    [alertController setValue:hogan forKey:@"attributedTitle"];

修改内容属性

key: attributedMessage

//修改message
    NSMutableAttributedString * attrMessage = [[NSMutableAttributedString alloc] initWithString:@"提示内容"];
    [attrMessage addAttribute:NSForegroundColorAttributeName value:[UIColor greenColor] range:NSMakeRange(0, [[attrMessage string] length])];
    [attrMessage addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:15] range:NSMakeRange(0, [[attrMessage string] length])];
    [alertController setValue: attrMessage forKey:@"attributedMessage"];

标题AlertAction按钮字体颜色

key: _titleTextColor或者titleTextColor

 //修改按钮的颜色,同上可以使用同样的方法修改内容,样式
    UIAlertAction *defaultAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:nil];
    UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil];

    [defaultAction setValue:[UIColor blackColor] forKey:@"_titleTextColor"];
    [cancelAction setValue:[UIColor blackColor] forKey:@"_titleTextColor"];

    [alertController addAction:defaultAction];
    [alertController addAction:cancelAction];

效果图

Snip20171214_4.png

实现自定义UIAlertController的iOS开发示例 随着移动应用的普及,用户界面(UI)的体验愈发重要。尤其在iOS平台上,UIAlertController扮演了至关重要的角色,用于提供及时的反馈和简短的交互。然而,随着设计要求的提升,开发者们发现,标准的UIAlertController无法完全满足所有个性化需求。为了更好地适应各种复杂场景,自定义UIAlertController成为了一个值得深入探讨的话题。 阅读详情

相关推荐

【opencv3 学习记录】第二章 读取显示保存视频

一:捕获视频函数 1.函数:cv2.VideoCapture(参数) 2.参数说明: (1)开启摄像头:参数一般为0,你可以通过设置成 1 或 者其他的来选择别的摄像头。 (2)从文件夹中获取视频:参数为字符串形式的文件路径 3.示例: cap = cv2.VideoCapture(0) #cap:存放参数 二:读取视频函数 1.函数:cap.read() 2.函数说明: (1)cap.read 中cap与捕获视频函数存放函数一致,可以自己命名.括号一般不用填写 (2)ret,f

m0_64448543的博客 3272

UIPickerView设置字体的方法

-(UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view{ UILabel *lbl = (UILabel *)view; if (lbl == nil) { lb

克莱斯勒的博客 1450

Abaqus子程序开发避坑指南:从UMESHMOTION到齿轮磨损分析实战

本文深入探讨Abaqus子程序开发中的关键技术与避坑指南,重点解析UMESHMOTION在齿轮磨损分析中的实战应用。从开发环境搭建、调试框架构建到性能优化和大规模计算,提供系统化的解决方案。通过真实案例展示如何避免内存泄漏、网格畸变等常见问题,并介绍数据驱动的磨损预测等前沿技术,帮助工程师提升仿真精度与效率。

weixin_30892037的博客 87

iOS UIAlertController 背景色以及字体设置

//创建UIAlertController let alertVC = UIAlertController(title: "修改家庭名称", message: nil, preferredStyle: .alert) //修改UIAlertController背景色 let subview = (alertVC.view.subviews.first?.subviews.first?.subviews.first!)! as UIView subview.backgroundC...

仰望心空1123 2994

手把手教你用RSoft BPM仿真一个1x2光分束器:从参数设置到结果分析全记录

本文详细介绍了使用RSoft BPM模块设计和仿真1×2光分束器的完整流程,包括参数设置、结构建模、仿真配置和结果分析。通过实战指南,帮助读者掌握光波导器件的仿真技术,实现50:50功率分配的设计目标,适用于光通信和集成光学领域的研究与应用。

weixin_30545945的博客 545

数据仓库从明细到汇总:DWD与DWS层建模实战指南

DWS层的“主题”是指业务分析的核心场景,通常分为“用户主题、商品主题、订单主题、营销主题”等。主题的定义需紧密结合业务需求,避免“为了汇总而汇总”。例如,电商平台的核心业务需求包括“用户活跃度分析”“商品销售情况分析”“订单转化分析”,对应的DWS层主题即可定义为“用户主题汇总表”“商品主题汇总表”“订单主题汇总表”。主题定义时需注意“粒度适中”——汇总粒度既不能过细(否则与DWD层重复,失去汇总意义),也不能过粗(否则无法满足细分分析需求)。

2401_83088008的博客 644

UIAlertController的使用以及对字体颜色大小的修改

UIAlertController的使用以及对字体颜色大小的修改

blueCat_1128的博客 4223

布尔可满足性问题(SAT)深度研究

布尔可满足性问题(Boolean Satisfiability Problem, SAT)是计算机科学和数理逻辑中的一个核心决策问题。其定义为:对于一个给定的布尔逻辑公式,判断是否存在一组对其变量的真值赋值(即,为每个变量指定真 (True) 或假 (False)),使得该公式的最终计算结果为真。如果存在这样的赋值,则称该布尔公式是可满足的 (satisfiable);否则,称其为不可满足的 (unsatisfiable)。

步子哥的博客 495

UIAlertController 修改 title 或 message 样式相关

UIAlertController 修改 title 或 message 样式相关

survivorsfyh的博客 525

四足狗机器人硬件开发技术栈详解

本文系统介绍了四足狗机器人的硬件开发技术,重点分析了五大核心模块:机械结构(骨架设计)、动力系统(关节驱动)、感知系统(环境监测)、控制系统(决策中枢)和电源系统(能源管理)。文章详细阐述了各模块的选型标准、技术要点和协同设计原则,提供了从需求定位到组装调试的完整开发流程,并针对常见问题给出解决方案。随着材料轻量化、模块标准化和AI集成化的发展趋势,四足机器人硬件将向更灵活、更智能的方向演进,为工业巡检、应急救援等场景提供更强大的移动平台支持。

start_up_go的博客 284

结构光相移法-多频外差原理与实践

结构光相移法是一种常用的三维形貌测量技术,它通过对投射到目标物体上的结构光进行相位调制和解调,实现对物体表面的三维重建。其中,多频外差原理是结构光相移法的核心原理之一,通过使用不同频率的结构光来实现相位测量,并可以提高测量精度和抗干扰性能。结构光相移法的多频外差原理是一种常用的三维形貌测量技术,它通过使用多个不同频率的结构光进行相位调制和解调,实现对物体表面的三维重建。本文介绍了多频外差原理的原理和实践应用,并提供了相应的Python源代码,希望对读者理解和应用结构光相移法有所帮助。

CodeByte的博客 737

UIAlertController 修改文字显示实现方法

UIAlertController修改文字显示 不废话先上完整代码 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 UIAlertController *alertController = [UIAlertController alertContr...

weixin_30693683的博客 172

Vue - 解决 Property or method “__v_isRef“ is not defined on the instance but referenced(浏览器控制台报错,代码没错)

vue,vue2控制台报错,vue报错Propertyormethod"__v_isRef"isnotdefinedontheinstancebutreferenced,vue代码没问题,但是报错Propertyormethod"__v_isRef"isnotdefinedontheinstancebutreferenced,vue2如何解决报错,vue怎么解决报错问题,vue2Propertyormethod"__v_isRef"isnotdefi

🏆 前端领域优质创作者 4501

多年iOS开发经验总结(二)

、设置UILabel行间距 NSMutableAttributedString* attrString = [[NSMutableAttributedString alloc] initWithString:label.text]; NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc] init]; ...

小天空的博客 713

lwip-2.0.3

lwip是瑞典计算机科学院(SICS)的Adam Dunkels 开发的一个小型开源的TCP/IP协议栈。实现的重点是在保持TCP协议主要功能的基础上减少对RAM 的占用。

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

[iOS]UIAlertController修改提示按钮文字颜色

系统提示按钮字体颜色默认是蓝色,因为是在项目优化时产生的需求故使用拓展的方式解决。 #import "UIAlertController+GSActionBtn.h" @implementation UIAlertController (GSActionBtn) + (void)load { // 只执行一次 static dispatch_once_t onceToke...

Gamin 3475

锂电池充电器电路设计 里面有电路

锂电池充电器电路设计 里面有电路 3.7V升压到5V电路设计。

iOS 改变UIAlertController的标题、内容的字体和颜色

在开发中,弹出框是必不可少的,通常情况下,我们只要弹出系统自带的弹出框就可以。but,在某些情况下,万恶的UI会要求你修改显示文字的大小、颜色,虽然系统自带有一种红色字体的UIAlertAction,但是这种Action并不能放在Cancel位置,所以,更多时候,需要我们自己修改文字字体和颜色。我采用的方法是KVC:1.标题和提示内容的文字设置代码如下://修改title NSMutabl...

H.A.N的博客 2436

最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版

Part-E1-SDIO-Specification-Ver4.00-Final-120220.pdf:最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版,包括SDIO 接口的外设,SDIO 接口官方协议等。

IOS 修改UIAlertController的按钮标题的字体颜色,字号,内容

现在只是实现了功能,原理是通过runtime获取对应的可以修改的key。具体还后续的学习中进行补充主要的代码://按钮点击- (IBAction)buttonClick:(UIButton *)sender { UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"提示" messa

CJXBShowZhouyujuan的博客 1万+

修改UIAlertController的字体颜色字号

(IBAction)buttonClick:(UIButton *)sender {UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@”提示” message:@”提示内容” preferredStyle:UIAlertControllerStyleAlert];//修改标题的内容,字号

IOS_ZhuJianan的博客 3038

XZ_iOS 之UIAlertController 修改title、message和action颜色、大小

效果图如下: 之前看了很多的博客,都是先获取 Ivar属性,然后判断是title还是message再进行修改,其实不用,可以直接拿到title和message进行修改,代码如下: /** 简单的文字弹窗,带’确定‘文字 @param title 题目 @param message 内容 @param target 目标控制器 */ + (void)showAlertWithT...

understand_XZ的博客 1061

KVC的妙用之UIAlertController的UIAlertAction外观改变

KVC的妙用之UIAlertController的UIAlertAction外观改变 2015-08-20 YuLongLi 大话swift 最近赶项目,也遇到了很多,无论是技术还是与同事的交往,感触颇深:1.不要理想的认为你方便了对方,对方就会给你方便;2.程序猿要注重沟通能力;3.学会制作开发计划,复杂的事情要分组来做;4。要学会整理项目 好了,还是切入今天的主题:大家对于K...

跬步的博客 528

UIAlertController更改内容样式及插入自定义View

iOS8 之后系统把UIActionSheet和UIAlertView合并为了UIAlertController,使用就不比多说了,但在使用的过程中发现样式是固定的,点进去也未发现可以提供更改多样式的属性,所以只能使用KVC在运行时动态访问和修改对象的属性。 但在使用过程中需要知道属性类型对应的key值,这里提供两个方法,是别人写好的,借用一下。 原文链接:帅气的链接 //获得所有变量 -

zhenhuiwan的博客 1万+

修改UIAlertController-action文字颜色

weixin_34148456的博客 141

修改UIAlertAction 的文字颜色

extension UIAlertAction {    func setTextColor(color: UIColor) {        var count: uint = 0;        let ivars =  class_copyIvarList(UIAlertAction.classForCoder(), &count)        for i in 0 ..

oiKen的博客 3159

iOS UIAlertController上修改标题(title) 消息(message) 按钮 的字体大小及颜色

iOS UIAlertController上修改标题(title) 消息(message) 按钮 的字体大小及颜色

四分之一工程师的博客 1万+

ios8之后的UIAlertController

昨天工程里需要将 UIActionSheet 中的颜色统一

写的比较乱 3110
上一篇: Swift 枚举
下一篇: HTTP网络请求 statusCode(状态码)
XR_Code
博客等级 码龄10年 16粉丝 15原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值