NSMutableAttributedString的使用】的更多相关文章

NSMutableAttributedString继承于NSAttributedString(带属性的字符串)能够简单快速实现富文本的效果;不多说直接上效果图和代码,通俗易懂: (一)效果图: (二)代码: UILabel *testLabel = [[UILabel alloc]initWithFrame:CGRectMake(, , [[UIScreen mainScreen] bounds].size.width, )]; testLabel.textAlignment = NSTextA…
NSMutableAttributedString *attrString = [[NSMutableAttributedString alloc]initWithString:@"我是富文本"]; //字体 [attrString addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:12.0] range:NSMakeRange(0, 2)]; //粗细 负为实体,正为中空 [attrString addAt…
NSMutableAttributedString计算高度的问题 _label_page2_1 = [[UILabel alloc] init]; _label_page2_1.numberOfLines = ; NSMutableAttributedString *attrString = [[NSMutableAttributedString alloc] initWithString:@"addAttribute:NSFontAttributeName value:[UIFont syst…
NSTextAttachment *attachment = [[NSTextAttachment alloc] init]; attachment.image = [UIImage imageNamed:@"mine_chat_popview_jinyan_icon"]; attachment.bounds = CGRectMake(0, -5, 21, 21); NSMutableAttributedString *attributed = [[NSMutableAttribute…
NSMutableAttributedString *msAttriStr = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"this is book ",departmentStr,departmentStatistics.d_count]]; //设置字体大小 [msAttriStr addAttributes:@{NSFontAttributeName:[UIFont…
1.设置字符串中数字字符串的颜色: // 设置字符串中数字的颜色 - (void)setTextColor:(UILabel *)label FontNumber:(id)font AndRange:(NSRange)range AndColor:(UIColor *)vaColor { NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:label.text]; NSCharact…
NSMutableAttributedString 是一个很强悍的富文本处理字符串,可以方便的实现一个字符串中某个字符的样式处理.我把我下面代码实现的功能步骤说一下:首先拼接两个字符串,然后给前前半部分和后半部分字符串分别实现不同样式,最后在给后半部分的字符串增加删除线.... 如果不用到NSMutableAttributedString 实现起来不但麻烦不说,而且不能保证百分之百的准确: 下面先截图 然后上代码 (←就是它了) NSDictionary *singleDictionary=[[…
计算 NSMutableAttributedString 高度,必须要有两个属性 -(void)test{ UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(, , , )]; label.backgroundColor = [UIColor redColor]; //可分行 label.numberOfLines = ; NSString *str = @"修改数据很明显是属于 model 层的任务.Model 应该为诸如删除或…
DJComposeViewController.m import "DJComposeViewController.h" #import "DJAccountTool.h" @implementation DJComposeViewController - (void)viewDidLoad { [super viewDidLoad]; [self initNavigationView]; [self initInputView]; } - (void)viewDi…
适用于:当你想对一个字符串中的某几个字符更改颜色,字体... NSString *string = @"今日营养配餐提供热量1800千卡,需要饮食之外额外补充钙10mg,铁20mg,锌9.5mg,叶酸200μgDFE,维生素D 10ug,维生素B1 1.2mg,维生素B2 1.2mg."; NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:str…