I want to keep custom fonts in iOS app. Currently, I'm using iOS default fonts. Is there any possible way for the same?
How do I include the custom font so that I can use it?
Go to Format > Font > Font. + D to open the Font dialog box. Select the font and size you want to use. Select Default, and then select Yes.
Make a category:
#import "UILabel+Helper.h"
@implementation UILabel (Helper)
- (void)setSubstituteFontName:(NSString *)name UI_APPEARANCE_SELECTOR {
self.font = [UIFont fontWithName:name size:self.font.pointSize]; }
@end
Then in AppDelegate.m:
[[UILabel appearance] setSubstituteFontName:@"SourceSansPro-Regular"];
This will change font in whole app even on UIButton, UILabel, inside UITableViewCell, UICollectionViewCell, UIView, UIContainerView, or anywhere in application without changing the font point size.
This is memory efficient approach rather than enumerating all views in your UIViewController.
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