首页 > 代码库 > iOS: 两句话给UILabel添加下划线

iOS: 两句话给UILabel添加下划线

1. 将UILabel控件的Text属性设为Attributed

2. 在viewDidLoad方法中添加如下语句:

NSDictionary *underlineAttribute = @{NSUnderlineStyleAttributeName: @(NSUnderlineStyleSingle)};lbPrivacy.attributedText = [[NSAttributedString alloc] initWithString:@"隐私政策"                                                             attributes:underlineAttribute];

Done.

iOS: 两句话给UILabel添加下划线