//设置价格数据
-(void)dealPriceSizeAndColor:(NSString *)priceStr{
NSString *currentPrice =[NSString stringWithFormat:@"您发布的商品的售价为¥%@元,请再次确认售价是否有误?",priceStr];
//创建Attributed
NSMutableAttributedString *noteStr =[[NSMutableAttributedString alloc]initWithString:currentPrice];
//需要改变的第一个文字的位置
NSUInteger startL =[[noteStr string]rangeOfString:@"为"].location + 1;
//需要改变的区间
NSUInteger finishL =[[noteStr string]rangeOfString:@"元"].location;
//需要改变的区间
NSRange range = NSMakeRange(startL,finishL - startL);
//改变颜色
[noteStr addAttribute:NSForegroundColorAttributeName value:TEXT_COLOR_RED range:range];
//改变字体大小及类型
[noteStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:18]range:range];
//为label添加Attributed
[_titleL setAttributedText:noteStr];
}
网友评论