jueves, 8 de octubre de 2015

iOS: Make UIViewController's view work both in iPhone 5 and iPhone 6

Create a base view controller overriding ViewDidLoad:

BaseViewController.m

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    CGRect frame = self.view.frame;
    CGRect anotherFrame = [UIApplication sharedApplication].keyWindow.frame;
    CGFloat scaleX = anotherFrame.size.width / frame.size.width;
    CGFloat scaleY = anotherFrame.size.height / frame.size.height;
    
    if(scaleX > 1 && scaleY > 1) {
        self.view.transform = CGAffineTransformMakeScale(scaleX, scaleY);
        
    }

    ...
}

No hay comentarios:

Publicar un comentario