UILabel *lable = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, ScreenW, 300)] ;
[self.view addSubview:lable] ;
NSMutableAttributedString *attrStr = [[NSMutableAttributedString alloc] initWithString:@""];
NSMutableAttributedString *attrStr2 = [[NSMutableAttributedString alloc] initWithString:@"你好,是我"];
NSMutableAttributedString *attrStr3 = [[NSMutableAttributedString alloc] initWithString:@"刘国彦"];
NSDictionary *attributeDict = @{NSFontAttributeName: [UIFont systemFontOfSize:18.0],
NSForegroundColorAttributeName: [UIColor redColor]};
NSDictionary *attributeDict2 = @{NSFontAttributeName: [UIFont systemFontOfSize:12.0],
NSForegroundColorAttributeName: [UIColor yellowColor]};
[attrStr2 setAttributes:attributeDict range:NSMakeRange(0, attrStr2.length)] ;
[attrStr3 setAttributes:attributeDict2 range:NSMakeRange(0, attrStr3.length)] ;
[attrStr appendAttributedString:attrStr2] ;
[attrStr appendAttributedString:attrStr3] ;
lable.attributedText = attrStr ;
暂无评论
要发表评论,您必须先 登录