In iOS 8, we can design a different UI layout for each size class. The issue I\'m facing is, I\'ve designed a layout for Compact Width and Regular Height (size class for all
Instead of writing code for each and every label, do just extend your label class with Your custom label class as below and it will automatically scale based on device resolution scaling factor:
#define SCALE_FACTOR_H ( [UIScreen mainScreen].bounds.size.height / 568 )
CustomLabel.h
#import
@interface CustomLabel : UILabel
@end
CustomLabel.m
#import "CustomLabel.h"
@implementation CustomLabel
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
// Drawing code
}
*/
- (id)initWithCoder:(NSCoder *)aDecoder {
if( (self = [super initWithCoder:aDecoder]) ){
[self layoutIfNeeded];
[self configurefont];
}
return self;
}
- (void) configurefont {
CGFloat newFontSize = (self.font.pointSize * SCALE_FACTOR_H);
self.font = [UIFont fontWithName:self.font.fontName size:newFontSize];
}
@end