我的代码中已经有了这个属性,但是如何添加下划线属性呢?
NSDictionary *attrs = [NSDictionary dictionaryWithObjectsAndKeys:
boldFont, NSFontAttributeName, foregroundColor, NSForegroundColorAttributeName, nil];
最佳答案
只需添加一个 NSUnderlineStyleAttributeName
键并将 @(NSUnderlineStyleSingle)
作为值:
NSDictionary *attrs = @{ NSFontAttributeName : boldFont,
NSForegroundColorAttributeName : foregroundColor,
NSUnderlineStyleAttributeName : @(NSUnderlineStyleSingle) };
关于ios - 如何在 UILabel 上为下划线创建属性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18819665/