
Could not find an overload init that accepts this supplIEd arguments
appDelegate中的代码:
UINavigationbar.appearance().TitleTextAttributes = [NSFontAttributename: UIFont(name: "Ubuntu",size: 17),NSForegroundcolorAttributename:UIcolor.whitecolor()]UIbarbuttonItem.appearance().setTitleTextAttributes([NSFontAttributename: UIFont(name: "Ubuntu-light",size: 15),NSForegroundcolorAttributename:UIcolor.whitecolor()],forState: UIControlState.normal)解决方法 最近有一个变化,所以UIFont(name:size :)返回一个可选的UIFont实例.你需要解开它们才能使它工作.使用!是最简单的方法,但如果字体不在系统上,会让您崩溃.尝试像:
let navbarFont = UIFont(name: "Ubuntu",size: 17) ?? UIFont.systemFontOfSize(17)let barbuttonFont = UIFont(name: "Ubuntu-light",size: 15) ?? UIFont.systemFontOfSize(15)UINavigationbar.appearance().TitleTextAttributes = [NSFontAttributename: navbarFont,NSForegroundcolorAttributename:UIcolor.whitecolor()]UIbarbuttonItem.appearance().setTitleTextAttributes([NSFontAttributename: barbuttonFont,forState: UIControlState.normal)总结
以上是内存溢出为你收集整理的ios – 在swift中更改titleTextAttribute全部内容,希望文章能够帮你解决ios – 在swift中更改titleTextAttribute所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)