4

I load view from bundle and try to set custom font for label in it, but nothing changes. Outlets for this view and labels are in file's owner. Here's my code:

    self.rikView = (RIKMainToolbar*)[[[NSBundle mainBundle] loadNibNamed:@"RIKMainToolbarPort" owner:self options:nil] objectAtIndex:0];
    label.font = [UIFont fontWithName:@"PFDinTextCondPro-Medium.ttf" size:46];

What am I doing wrong?

UPD: I use this font in iPhone app, but there it's using for label in ViewController and sets in viewDidLoad function. And it works. So, I consider that problem is in loadWithNibName or in iPad.

Solved, thanks to @voromax. The problem was that labels' outlets belonged to file's owner. I've replace it with class and everything works)

Arun_
  • 1,706
  • 1
  • 19
  • 37

3 Answers3

2

I'm not sure I follow your code exactly, but assuming you're making the label.font assignment in initWithFrame of RIKMainToolbarPort, try moving it to the awakeFromNib method.

Ashley Mills
  • 44,005
  • 15
  • 120
  • 151
1

Open the FontBook application, and select "view font info". Copy the post-script-name of your desired font, and use that in your Obj-C code

Audun Kjelstrup
  • 1,430
  • 8
  • 13
1

You are not using the correct font name. You seem to be using the font file's name, NOT the font name. For example, in my current app I have the file Opal_1.ttf. However, I use "Opal" as the font name.

[edit]Meh, check the example here: https://stackoverflow.com/a/1384206/855738 Again, I repeat, your font name is wrong. That's your problem... Why the down vote? :/

Community
  • 1
  • 1
BBog
  • 3,560
  • 5
  • 31
  • 63