ios-NSMutableAttributedString 更改文本字符串颜色、大小

- NSString * string = [NSString stringWithFormat:@"您的号码是%@号",[self backString:dic[@"rankNumber"]]];
- NSString * rankNumber = [NSString stringWithFormat:@"%@",[self backString:dic[@"rankNumber"]]];
- NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:string];
- [str addAttribute:NSForegroundColorAttributeName value:YellowColor range:NSMakeRange(5,rankNumber.length)];//(5,2) 2是位数
- [str addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"HelveticaNeue" size:FontOfSize19*kWidth] range:NSMakeRange(5, rankNumber.length)];
- _orderNumber.attributedText = str;
- NSString * string1 = [NSString stringWithFormat:@"您前面还有%@位司机在等待",[self backString:dic[@"frontNumber"]]];
- NSString * frontNumber = [NSString stringWithFormat:@"%@",[self backString:dic[@"frontNumber"]]];
- NSMutableAttributedString *str1 = [[NSMutableAttributedString alloc] initWithString:string1];
- [str1 addAttribute:NSForegroundColorAttributeName value:YellowColor range:NSMakeRange(5,frontNumber.length)];//(5,2) 2是位数
- [str1 addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"HelveticaNeue" size:FontOfSize19*kWidth] range:NSMakeRange(5, frontNumber.length)];
- _waitNumber.attributedText = str1;
- NSString * number = [NSString stringWithFormat:@"待运单%@",[self backString:dic[@"orderNumber"]]];
- _waitOrder.text = number;
ios-NSMutableAttributedString 更改文本字符串颜色、大小的更多相关文章
- iOS 设置文本中指定某段文本的颜色 大小
NSString *money = @"300"; NSString *perStr = @"元/时"; NSString *text = [NSString ...
- iOS - NSMutableAttributedString富文本的实现
NSMutableAttributedString继承于NSAttributedString(带属性的字符串)能够简单快速实现富文本的效果;不多说直接上效果图和代码,通俗易懂: (一)效果图: (二) ...
- (转)解决NSMutableAttributedString富文本,不同文字大小水平轴对齐问题(默认底部对齐)
默认是底部对齐,其实对的也不齐, 目标效果: 代码: NSBaselineOffsetAttributeName 基线偏移量: 调整: NSBaselineOffsetAttributeName的值 ...
- MarkDown编辑器中改变文本字体颜色大小
法一 有点类似前端里 <font face="微软雅黑" size=4 color=red>输入的文字</font> 其中 face对应字体 size 大小 ...
- iOS修改TextField占位符颜色大小
UITextField *addCtrolField = [[UITextField alloc]initWithFrame:CGRectMake(CGRectGetMaxX(rightTitleLa ...
- iOS 开发富文本之TTTAttributedLabel 在某个特定位置的文字添加跳转,下划线,修改字体大小,颜色
@property(nonatomic , strong) TTTAttributedLabel * ttLabel; @property(nonatomic , strong) NSRange li ...
- iOS开发富文本制作 图片和文字/NSMutableParagraphStyle/NSMutableAttributedString
/NSMutableParagraphStyle/NSMutableAttributedString 组合使 NSString * titlestr=@"日产GT-R"; NSMu ...
- 【MFC系列】MFC快速设置控件文本字体、大小、颜色、背景
以静态文本为例,分享一下怎么修改文本字体.大小.颜色.背景等参数.其他文本.控件等可参照修改. 1.修改字体.大小 这个很简单,首先在Dlg类中声明一个CFont类型的成员变量: 然后在类的初始化函数 ...
- iOS开发笔记-根据frame大小动态调整fontSize的自适应文本及圆形进度条控件的实现
最近同样是新App,设计稿里出现一种圆形进度条的设计,如下: 想了想,圆形进度条实现起来不难,但是其中显示百分比的文本确需要自适应,虽然可以使用时自己设定文本字体的大小,但是这样显得很麻烦,也很low ...
随机推荐
- Spring进阶—如何用Java代码实现邮件发送(二)
http://www.cnblogs.com/itsource/p/4266905.html
- 解决$.getJSON在IE浏览器下出现数据缓存,第一次访问某个后台路径之后,再次访问该路径不再走后台的方法。
最近写代码的时候遇到一个小问题,我用的是火狐,项目里测试人员用的是IE,当用jquery的getjson函数从后台获取数据的时候,IE浏览器会自动设置缓存,如果此时你对数据进行修改的时候刷新页面,IE ...
- ArcGIS 最短路径计算
using System;using ESRI.ArcGIS.Carto;using ESRI.ArcGIS.Geometry;using ESRI.ArcGIS.Geodatabase;using ...
- Linux crontab 定时任务命令详解
一.简介 crontab 命令用于设置周期性被执行的指令.该命令从标准输入设备读取指令,并将其存放于 crontab 文件中,以供之后读取和执行.通常,crontab 储存的指令被守护进程激活, cr ...
- iOS学习31之UITableVIewCell自定义
1. 自定义Cell 1> 为什么要自定义Cell UITableView 中系统的Cell共提供了四种默认样式, 分别是: UITableViewCellStyleDefault UITab ...
- BZOJ3542:DZY Loves March
询问是要求 $\sum_{i=1}^n((x[i]-a)^2+(y[i]-b)^2)(x[i]=a||y[i]=b)$ 即求 $\sum_{i=1}^n(x[i]-a)^2(y[i]=b)+\sum_ ...
- WPF standard ComboBox Items Source Change Issue
Today I encountered an issue with the WPF standard CombBox where if the bound ItemsSource (collectio ...
- AFNetworking 2.0 出现Use of undeclared identifier AFURLSessionManager错误
当向下面使用时会出现错误 #import "AFNetworking.h" #import "AFURLSessionManager.h" AFURLSessi ...
- POJ 2420 A Star not a Tree?(模拟退火)
题目链接 居然1Y了,以前写的模拟退火很靠谱啊. #include <cstdio> #include <cstring> #include <string> #i ...
- 不错的判断 UITextView 内容不超过20个字符串的方法
- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSSt ...