为 iOS5+(包括 iOS7)提供简单的启动屏 + 动画制作器。
YISplashScreen
在状态栏之上创建另一个 UIWindow,使过渡更加平滑,与直接在 mainWindow.rootViewController.view
上添加启动图像相比。animationBlock
使用两个参数来隐藏启动图像:splashLayer
:启动图像层rootLayer
:对 mainWindow.rootViewController.view.layer
的复制- (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];
}];
通过使用 [YISplashScreen showAndWaitForMigration:completion:]
(可选),您可以轻松集成简单的 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
基于 啤酒许可证 提供使用。
如果我们某天见面,并且你认为这些内容值得,你可以买我一杯啤酒作为回报。