I am working on universal application.
I am using size classes for that but I am facing some problem related to custom fonts.
I have created custom label class and apply that to over UILabel. Below is my MyLabel.h file.
MYLabel.h
#import <UIKit/UIKit.h>
@interface MyLabel : UILabel
@end
Below is my MyLabel.m file.
#import "MyLabel.h"
@implementation MyLabel
- (void)drawRect:(CGRect)rect {
}
-(void)awakeFromNib {
UIFont *custom = [[UIFont alloc] init];
custom = [UIFont fontWithName:@"MyriadPro-SemiboldIt" size:18];
self.font = custom;
}
@end
After that I have given MyLabel class to UILabel.
And set the property according to the below picture.
Though I am not able to see change in my font.It shows same font for Ipad and Iphone.
please help me out.I am newbie in Size Classes.
Thanks in advance.
I got the answer. Just write below code in your MyLabel.m
file instead of awakeFromNib method.
- (void)layoutSubviews
{
[super layoutSubviews];
// Implement font logic depending on screen size
self.font = [UIFont boldSystemFontOfSize:5.0f];
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.