[[UINavigationbar appearance] setTitleTextAttributes:@{NSForegroundcolorAttributename : [UIcolor redcolor],// NSUnderlinestyleAttributename: @(NSUnderlinestyleSingle),(Nsstring *) kCTUnderlinestyleAttributename:@(kCTUnderlinestyleDouble),NSFontAttributename: [UIFont FontWithname:@"HelveticaNeue-Bold" size:17]}];
但它不起作用,我知道另一种方法,使用NSAttributedString创建自定义UILabel并在TitleVIEw上设置它,但有没有其他方法来实现这个使用外观协议?
解决方法 NSUnderlinestyleAttributename应该为您完成这项工作.试试这个Dude:
NSDictionary *attributes = @{ NSUnderlinestyleAttributename: @1,NSForegroundcolorAttributename : [UIcolor redcolor],NSFontAttributename: [UIFont FontWithname:@"HelveticaNeue-Bold" size:17] }; [[UINavigationbar appearance] setTitleTextAttributes:attributes];
更新:
我提到Apple的文档,似乎不可能通过外观协议.
它说
“您可以使用Nsstring UIKit Additions Reference中描述的文本属性键为文本属性字典中的标题指定字体,文本颜色,文本阴影颜色和文本阴影偏移.”
我也试过创建新的简单项目.看不到这条线.
Apple文件:
UINavigationBar
NSString Keys for Text Attributes Dictionaries
总结以上是内存溢出为你收集整理的ios – 带有UnderLine Text的UINavigationBar setTitleTextAttributes全部内容,希望文章能够帮你解决ios – 带有UnderLine Text的UINavigationBar setTitleTextAttributes所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)