我正在尝试使用以下代码在所有视图中设置带有下划线的文本属性:
setTextAttribute
[[UINavigationBar appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor redColor],
// NSUnderlineStyleAttributeName: @(NSUnderlineStyleSingle),
(NSString *) kCTUnderlineStyleAttributeName:@(kCTUnderlineStyleDouble),
NSFontAttributeName: [UIFont fontWithName:@"HelveticaNeue-Bold" size:17]}];
但它没有起作用,我知道另一种方法是使用创建自定义的UILabel
,并使用NSAttributedString
将其设置在TitleView上,但是否有其他方法可以使用外观协议来实现这一点?