har*_*ios 3 xcode fonts objective-c ios
我正在尝试setTextAttribute
使用此代码在所有视图中使用UnderLine
[[UINavigationBar appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor redColor],
// NSUnderlineStyleAttributeName: @(NSUnderlineStyleSingle),
(NSString *) kCTUnderlineStyleAttributeName:@(kCTUnderlineStyleDouble),
NSFontAttributeName: [UIFont fontWithName:@"HelveticaNeue-Bold" size:17]}];
Run Code Online (Sandbox Code Playgroud)
但它不工作,我知道通过创建自定义的另一种方法UILabel
与NSAttributedString
和设置它在titleview的,但没有任何其他的方式来实现这一目标使用外观协议?
NSUnderlineStyleAttributeName应该为您完成这项工作.
试试这个Dude:
NSDictionary *attributes = @{
NSUnderlineStyleAttributeName: @1,
NSForegroundColorAttributeName : [UIColor redColor],
NSFontAttributeName: [UIFont fontWithName:@"HelveticaNeue-Bold" size:17]
};
[[UINavigationBar appearance] setTitleTextAttributes:attributes];
Run Code Online (Sandbox Code Playgroud)
更新:
我提到Apple的文档,似乎不可能通过外观协议.
它说
"您可以使用NSString UIKit Additions Reference中描述的文本属性键为文本属性字典中的标题指定字体,文本颜色,文本阴影颜色和文本阴影偏移."
我也试过创建新的简单项目.看不到这条线.
Apple文件:
归档时间: |
|
查看次数: |
3303 次 |
最近记录: |