获取我们添加到Assets.xcassets的LaunchImage
配置启动图片如下所示
launchimage获取这里面图片的名字做一些操作,我们代码如下
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
self.window = [[UIWindow alloc]initWithFrame:[UIScreen mainScreen].bounds];
CGSize viewSize = self.window.bounds.size;
NSLog(@"nrect = %@",NSStringFromCGRect(self.window.bounds));
NSString * viewOrientation = @"Portrait";
NSString * launchImage = nil;
NSArray * imageDict = [[[NSBundle mainBundle] infoDictionary]valueForKey:@"UILaunchImages"];
for (NSDictionary * dict in imageDict) {
CGSize imageSize = CGSizeFromString(dict[@"UILaunchImageSize"]);
if (CGSizeEqualToSize(imageSize, viewSize) && [viewOrientation isEqualToString:dict[@"UILaunchImageOrientation"]]) {
launchImage = dict[@"UILaunchImageName"];
}
}
NSLog(@"==luanch = %@",launchImage);
UIImageView * luanchView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:launchImage]];
self.window.backgroundColor = [UIColor whiteColor];
luanchView.frame = self.window.bounds;
luanchView.contentMode = UIViewContentModeScaleAspectFill;
[self.window addSubview:luanchView];
[UIView animateWithDuration:2.0f delay:1.0f usingSpringWithDamping:0.5f initialSpringVelocity:1.0 options:UIViewAnimationOptionCurveLinear animations:^{
luanchView.alpha = 0.0f;
luanchView.layer.transform = CATransform3DScale(CATransform3DIdentity, 0.8, 0.8, 1);
} completion:^(BOOL finished) {
luanchView.layer.transform = CATransform3DIdentity;
[luanchView removeFromSuperview];
}];
self.window.rootViewController = [UIViewController new];
[self.window makeKeyWindow];
return YES;
}
代码不多,就不用测试demo了,可以直接用代码测试一下,用到了就记录一下,大神还有更好的方法可以给我留言
网友评论