创建uilabel对象
UILabel*Label2 = [[UILabel alloc]initWithFrame:CGRectMake(0, 0,100, 25)];
//设置下划线属性
NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:@"文字下带下划线?"];
[straddAttribute:NSForegroundColorAttributeName value:[UIColor blueColor] range:NSMakeRange(0,8)];
[straddAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleSingle] range:NSMakeRange(0, 8)];
Label2.attributedText= str;
效果
网友评论