iOS启动图(两种方法)

如果你是按步骤使用的,点个赞吧

一、直接使用图片
1、拖入图片LaunchImage
2、buildSetting 搜索Asset Catalog设置名称为LaunchImage
3、进入Gernernal设置APP LaunchImage Source名称为LaunchImage
4、Launch Screen File设为空
5、点击LaunchScreen.storyborad,右侧Use a s Launch Screen不打勾
6、卸载app重新启动即可
二、自定义动画,代码如下

-(void)startWindowAnimation{
    NSDictionary * dict = @{@"320x480" : @"LaunchImage-700", @"320x568" : @"LaunchImage-700-568h", @"375x667" : @"LaunchImage-800-667h", @"414x736" : @"LaunchImage-800-Portrait-736h",@"375x812" : @"LaunchImage-800-Portrait-812h",@"414x896":@"LaunchImage"};
    NSString * key = [NSString stringWithFormat:@"%dx%d", (int)[UIScreen mainScreen].bounds.size.width, (int)[UIScreen mainScreen].bounds.size.height];
    UIImage * launchImage = [UIImage imageNamed:dict[key]];
    UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, __kScreenWidth, __kScreenHeight)];
    imageView.image = launchImage;
    
    [self.window addSubview:imageView];
    [self.window bringSubviewToFront:imageView];
    [UIView animateWithDuration:1 animations:^{
        imageView.alpha = 0;
        
        CAKeyframeAnimation *bounceAnimation = [CAKeyframeAnimation animationWithKeyPath:@"transform.scale"];
        bounceAnimation.values = @[@(1.0) ,@(1.1), @(1.2), @(1.3), @(1.4), @(1.5), @(1.6)];
        bounceAnimation.duration = 1.5;
        bounceAnimation.calculationMode = kCAAnimationCubic;
        [imageView.layer addAnimation:bounceAnimation forKey:@"bounceAnimation"];
    } completion:^(BOOL finished) {
        [imageView removeFromSuperview];
    }];
}

你可能感兴趣的:(iOS启动图(两种方法))