Skip to content

Instantly share code, notes, and snippets.

@rynbyjn
Last active December 22, 2015 20:29
Show Gist options
  • Save rynbyjn/6526591 to your computer and use it in GitHub Desktop.
Save rynbyjn/6526591 to your computer and use it in GitHub Desktop.
Category to fix PhoneGap 2.x CDVSplashScreen for updated iOS7 status bar rendering.
//
// CDVSplashScreen+Overrides.h
//
// Created by boyajian on 9/10/13.
//
//
#import "CDVSplashScreen.h"
@interface CDVSplashScreen (Overrides)
@end
//
// CDVSplashScreen+Overrides.m
//
// Created by boyajian on 9/10/13.
//
//
#import "CDVSplashScreen+Overrides.h"
@implementation CDVSplashScreen (Overrides)
- (void)updateBounds
{
UIImage* img = _imageView.image;
CGRect imgBounds = CGRectMake(0, 0, img.size.width, img.size.height);
CGRect viewBounds = self.viewController.view.bounds;
CGFloat imgAspect = imgBounds.size.width / imgBounds.size.height;
CGFloat viewAspect = viewBounds.size.width / viewBounds.size.height;
// This matches the behaviour of the native splash screen.
CGFloat ratio;
if (viewAspect > imgAspect) {
ratio = viewBounds.size.width / imgBounds.size.width;
} else {
ratio = viewBounds.size.height / imgBounds.size.height;
}
imgBounds.size.height *= ratio;
imgBounds.size.width *= ratio;
_imageView.frame = imgBounds;
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment