字符串的截取-设置字符串中某些文字的颜色
2017-05-17 00:00
204 查看
效果图:
Snip20160624_1.png
注意:
Snip20160624_1.png
注意:
1、其中count是一个数字,例如:5,即5人赞过中的数字5。 2、_countLabel 是UILabel类型的一个控件。
// 通过截取的方式,来设置***人赞过中数字的颜色 NSString*string = [NSString stringWithFormat:@"%ld人赞过",(long)count]; NSMutableAttributedString*attributeString = [[NSMutableAttributedStringalloc] initWithString:string]; NSRange range = [string rangeOfString:[NSString stringWithFormat:@"%ld",(long)count]]; [attributeString addAttribute:NSForegroundColorAttributeName value:RGBCOLOR(246, 153,19) range:range]; // 使用UILabel的attributedText 属性来赋值。 _countLabel.attributedText= attributeString;
相关文章推荐
- 字符串的截取-设置字符串中某些文字的颜色
- android 设置字符串中包含相关文字设置文字颜色
- 设置一段文字中某些特定的文字可点击,且文字颜色变色
- 安卓设置某些文字的字体颜色
- iOS开发 字符串中截取关键字并给他设置颜色
- iOS开发:字符串设置指定内容的文字颜色、文字大小、文字字体类型
- android--设置TextView部分文字的颜色和背景(高亮显示)
- android--设置TextView部分文字的颜色和背景(高亮显示)
- JTextPane例子,演示为文字设置字体、字号、样式、颜色、背景色和插入图片功能
- 鼠标选中输入文本框中某些文字后怎么变文字颜色?
- GridView 中设置某列,截取字符串加"..." 和 鼠标放上去字符全部显示
- 设置TextView个别文字字体颜色格式
- 设置CButtonST按钮文字颜色
- 如何设置richedit的默认背景色和文字颜色
- GridView 中设置某列,截取字符串加"..." 和 鼠标放上去字符全部显示 .
- CSS截取字符串,多余文字省略号显示
- JTextPane例子,演示为文字设置字体、字号、样式、颜色、背景色和插入图片功能
- android--设置TextView部分文字的颜色和背景(高亮显示)
- 自定义控件--xp风格按钮(可设置文字颜色)-http://www.cngr.cn/article/54/68/2006/2006071942717.shtml
- c#字符串截取文字省略[WEB学习示例]