简体   繁体   English

在iOS 8和swift中更改UITableViewCell字体

[英]Change UITableViewCell Font in iOS 8 and swift

I'm trying to change the font for my uitableviewcells, 我正在尝试更改我的uitableviewcells的字体,

I'm trying to use this at the moment with not success: 我目前正试图使用​​这个并没有成功:

cell.textLabel.font = [UIFont .preferredFontForTextStyle("Avenir")];

Now i've read a lot on this and it seems I should use this instead : 现在我已经阅读了很多内容,似乎我应该使用它:

    cell.textLabel.font = [UIFont fontWithName: "Avenir" size:22];

Problem is fontWithName does not seem to exist in iOS 8 问题是在iOS 8中似乎不存在fontWithName

any ideas?? 有任何想法吗??

thanks 谢谢

The thing is that this is not Swift (it is a kind of horrifying bastardization of Objective-C): 问题是这不是Swift(它是Objective-C的一种可怕的混蛋):

cell.textLabel.font = [UIFont fontWithName: "Avenir" size:22];

This would be Swift: 这将是斯威夫特:

cell.textLabel.font = UIFont(name:"Avenir", size:22)

尝试以下铸造方式:

cell.textLabel.font = UIFont(name: "Avenir", size:22);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM