最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
iOS 更改UILabel某些字体样式方法
时间:2022-06-26 06:01:06 编辑:袖梨 来源:一聚教程网
废话不多说了,大家先看下代码吧,具体待明日如下所示:
| 代码如下 | 复制代码 |
//str:要改变的字 //result:整个label里的字 //color: 字的颜色 - (NSMutableAttributedString *)changeSomeText:(NSString *)str inText:(NSString *)result withColor:(UIColor *)color { NSMutableAttributedString *attributeStr = [[NSMutableAttributedString alloc] initWithString:result]; NSRange colorRange = NSMakeRange([[attributeStr string] rangeOfString:str].location,[[attributeStr string] rangeOfString:str].length); [attributeStr addAttribute:NSForegroundColorAttributeName value:color range:colorRange];
returnattributeStr; } | |
效果:
相关文章
- 有哪些收号平台 04-28
- 红色沙漠火焰双手锤获取方法 04-28
- 崩坏星穹铁道丹恒腾荒何时上线 04-28
- 《The Sheep Detectives》评测 04-28
- 27年发售悬了 《刺客信条 女巫》被曝50人集体调离 04-28
- 异环别有洞天越狱方式详解-别有洞天如何逃离监狱 04-28
