大佬教程收集整理的这篇文章主要介绍了自定义文本颜色和UITabBarItem的字体导致怪异导致swift,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
UITabBarItem.appearance().settitleTextAttributes([NSForegroundColorAttributename: UIColor.blackColor()],forState:.Normal) UITabBarItem.appearance().settitleTextAttributes([NSForegroundColorAttributename: UIColor.whiteColor()],forState:.SELEcted)
@L_301_1@
但是,如果添加:
UITabBarItem.appearance().settitleTextAttributes([NSFontAttributename:UIFont(name: "American Typewriter",size: 13)!],forState: .SELEcted)
由于某种原因,当文本被选中和未被选中时,文本变为黑色,并且字体保持不变.
奇怪的是,如果我更改.在最后一个片段中选择.Normal,那么所选文本将变为白色,文本将与代码中的字体匹配.
UITabBarItem.appearance().settitleTextAttributes([NSFontAttributename:UIFont(name: "American Typewriter",forState: .Normal)
这几乎是完美的,但是未选择的文本现在没有变化.我不确定我做错了什么或这是一个错误,但如果有任何其他方法来完成这项任务,我很乐意听到它.
UITabBarItem.appearance().settitleTextAttributes([NSForegroundColorAttributename: UIColor.blackColor(),NSFontAttributename : [NSFontAttributename:UIFont(name: "American Typewriter",size: 13)!]],forState:.SELEcted) UITabBarItem.appearance().settitleTextAttributes([NSForegroundColorAttributename : UIColor.whiteColor(),forState:.Normal)
现在应用程序崩溃了.错误说:
这对我没有任何意义
let colorNormal : UIColor = UIColor.blackColor() let colorSELEcted : UIColor = UIColor.whiteColor() let titleFontAll : UIFont = UIFont(name: "American Typewriter",size: 13.0)! let attributesnormal = [ NSForegroundColorAttributename : colorNormal,NSFontAttributename : titleFontAll ] let attributesSELEcted = [ NSForegroundColorAttributename : colorSELEcted,NSFontAttributename : titleFontAll ] UITabBarItem.appearance().settitleTextAttributes(attributesnormal,forState: .Normal) UITabBarItem.appearance().settitleTextAttributes(attributesSELEcted,forState: .SELEcted)
以上是大佬教程为你收集整理的自定义文本颜色和UITabBarItem的字体导致怪异导致swift全部内容,希望文章能够帮你解决自定义文本颜色和UITabBarItem的字体导致怪异导致swift所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。