18

I'm trying to change the font for my 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

any ideas??

thanks

Jp4Real
  • 1,982
  • 4
  • 18
  • 33

2 Answers2

48

The thing is that this is not Swift (it is a kind of horrifying bastardization of Objective-C):

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

This would be Swift:

cell.textLabel.font = UIFont(name:"Avenir", size:22)
matt
  • 515,959
  • 87
  • 875
  • 1,141
2

Try the following casting way:

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