2

I'm using a custom font on an iPhone app. This font is used on UIButtons and is displaying well.

In IB, I'm setting up horizontal alignement to center and changing the font programaticly with :

[self.playButton.titleLabel setFont:[UIFont fontWithName:@"myfont" size:30]];

when the viewDidLoad is reached.

On the screen, when the view appear, the button's label is first left-aligned in my button and then, 1/2 sec later, it switch to center like I want.

It looks really strange ... if anyone have a clue about this, thanks a lot !

EDIT:

When using

[self.playButton.titleLabel setTextAlignment:UITextAlignmentCenter];

It's nearly the same, the text is cut and then appears totaly.

choomz
  • 135
  • 11
  • Have you tried setting the font in viewWillAppear? (I know this happens after viewDidLoad but hey I try everything). Also, is this the first time the font is used in this app (After app launch)? If so, try using it (causing it to load without displaying any actual text on screen) when the app loads - in case it gets cached and loads faster a second time it's used. BTW, I'm assuming this is on the device when it's not plugged into the mac? – ader Nov 10 '11 at 16:45
  • Hello, I tried in viewWillAppear and viewDidLoad. The font is used on all the app's UIButtons and so it appears in every screens. There is no difference, iPhone plugged or not plugged. It's very strange ... – choomz Nov 14 '11 at 14:13
  • Only other thing I found is this: "In an attempt to eliminate this initial UIButton lag I added another UILabel containing the entire alphabet and set it to .hidden=YES; This solved the UIButton lag problem. The issue now is that I'm clocking about 20secs before the app loads, from launch to use. Unacceptable. Has anyone else found a faster or more efficient way to do this?" I found that on www.iphonedevsdk.com but don't want to link as google tells me that site has malware at the moment... – ader Nov 14 '11 at 16:49
  • Still don't work .. because it's a custom font, so I can't set it via IB. I need to set the font label in the viewDidLoad/Appear and so it's the same. I discuted about that with many people and no one can tell me where it come from. It looks like a strange bug ... – choomz Nov 16 '11 at 08:19
  • I would also try other custom fonts to see if it's an issue with having to do a lot of processing for that font? – ader Nov 16 '11 at 11:31

1 Answers1

1

I am having EXACTLY the same problem. It appears using (sorry for the code, is Xamarin.iOS's C#, not obj-c) UILabel.Appearance.Font = UIFont.FromFile... Removing that let me set font even in the ViewDidLoad!

Brad Moore
  • 316
  • 5
  • 23