Easy splash screen + animation maker for iOS5+.
YISplashScreen
creates another UIWindow on top of status-bar so that transition will be nicer, compared to adding splash image directly onrootViewController.view
.animationBlock
is used to hide splash image with two arguments:splashLayer
: splash image layer (superlayer = another window, by default)rootLayer
: equivalent torootViewController.view.layer
(superlayer = main window)
Normally, animating splashLayer
and rootLayer
individually on separate UIWindows is sufficient,
but if you want to put them in one main window during animation,
prepare it by setting shouldMoveSplashLayerToMainWindowBeforeAnimation = YES
so that splashLayer.superlayer
will be main window (below status-bar) instead,
and more importantly, it prevents from layer-flickering.
Install via CocoaPods
pod 'YISplashScreen'
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// show splash
[YISplashScreen show];
// simple fade out
[YISplashScreen hide];
return YES;
}
// simple fade out
[YISplashScreen hide];
// cube
[YISplashScreen hideWithAnimation:[YISplashScreenAnimation cubeAnimation]];
// manually add animation
[YISplashScreen hideWithAnimationBlock:^(CALayer* splashLayer, CALayer* rootLayer) {
// splashLayer moves up
[CATransaction begin];
[CATransaction setAnimationDuration:0.7];
[CATransaction setAnimationTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
splashLayer.position = CGPointMake(splashLayer.position.x, splashLayer.position.y-splashLayer.bounds.size.height);
[CATransaction commit];
}];
By using [YISplashScreen showAndWaitForMigration:completion:]
(optional), you can easily integrate simple UIAlertView-confirmation UI.
[YISplashScreen showAndWaitForMigration:^{
//
// NOTE: add CoreData migration logic here
//
NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption,
[NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption, nil];
[persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType
configuration:nil
URL:url
options:options
error:nil];
} completion:^{
[YISplashScreen hide];
}];
YISplashScreen
is available under the Beerware license.
If we meet some day, and you think this stuff is worth it, you can buy me a beer in return.