iOS   发布时间:2022-05-03  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了ios – 带有UnderLine Text的UINavigationBar setTitleTextAttributes大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

概述

我正在尝试使用此代码在所有视图中使用UnderLine setTextAttribute [[UINavigationBar appearance] settitleTextAttributes:@{NSForegroundColorAttributename : [UIColor redColor], // NSUnderlinestyleAttributename: @(NSUn
我正在尝试使用此代码在所有视图中使用UnderLine setTextAttribute

[[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中描述的文本@L_616_5@键为文本@L_616_5@字典中的标题指定字体,文本颜色,文本阴影颜色和文本阴影偏移.”

我也试过创建新的简单项目.看不到这条线.

Apple文件

UINavigationBar

NSString Keys for Text Attributes Dictionaries

大佬总结

以上是大佬教程为你收集整理的ios – 带有UnderLine Text的UINavigationBar setTitleTextAttributes全部内容,希望文章能够帮你解决ios – 带有UnderLine Text的UINavigationBar setTitleTextAttributes所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。