I'm trying to apply a custom font throughout my iOS app
. I found that I could use:
[[UILabel appearance] setFont:[UIFont fontWithName:@"Proxima Nova" size:17.0]];
To set the default font and size for all UILabels
. However, not all my UILabels
share the same font size.
In Set a default font for whole iOS app?, someone had the same concern, and was told to set the size parameter to 0.0 to only set the font and not font size.
UILabel
text in my app disappeared (because evidently iOS
took the 0.0 font size literally). Any suggestions as to how I can universally set a font but not size? Thanks a lot!
You can download fonts from the App Store app , then use them in documents you create on iPhone. After you download an app containing fonts from the App Store, open the app to install the fonts. To manage installed fonts, go to Settings > General, then tap Fonts.
Press the Settings button in the upper-right corner of the screen. Tap on Fonts. Under the Select Font list, choose your desired font style. Tap Done.
- (void)viewDidLoad { [super viewDidLoad]; [self setFontFamily:@"FagoOfficeSans-Regular" forView:self.view andSubViews:YES]; } -(void)setFontFamily:(NSString*)fontFamily forView:(UIView*)view andSubViews:(BOOL)isSubViews { if ([view isKindOfClass:[UILabel class]]) { UILabel *lbl = (UILabel *)view; [lbl setFont:[UIFont fontWithName:fontFamily size:[[lbl font] pointSize]]]; } if (isSubViews) { for (UIView *sview in view.subviews) { [self setFontFamily:fontFamily forView:sview andSubViews:YES]; } } }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With