UILabel带下划线实现
2018-04-18 本文已影响0人
andy_tu
创建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;
效果
