2015-06-22 56 views
1

是否有可能因为GIF不接受申请了iOS推出现场动画效果吗?动画为iOS启动图像

+1

您可以添加启动场景的精确副本作为场景的第一张图像,并从那里上制作动画。 –

+0

感谢您的回复,但没有明白您的意思。 – James

+0

启动图像不能动画 –

回答

3

编号启动场景是图像或LaunchScreen.xib。两者都是静态的。

但是,您可以出现在您的实际应用中类似于启动图像的GIF如果应用程序加载完毕后,将动画。

如果使用启动图像,创建的最初的viewController中的所有其他内容上面一个UIImageView。然后,您为该图像视图添加动画。 LaunchScreen.xib也一样,重新构建LaunchScreen.xib设置作为初始视图控制器,然后根据它创建一些自定义动画。

2

启动图像是静态的,可以配置它们与Xcode和你不能改变它们。但在启动画面中,您可以做任何你喜欢的事情,它只是一个viewController,你可以在其中显示动画,视频或其他任何东西。在启动图像之后和“着陆页”之前显示启动画面。然后,在闪屏中,您可以逐帧创建动画,或者在MPMoviePlayerController中加载.mp4视频。感谢

0

我对你有一个可能的解决方案:

  1. 设置闪屏图像作为第一帧的gif动画
  2. 在您的appDelegate创建用于显示视频,例如方法。 注意:将闪屏图像添加到窗口框架,直到视频准备播放。 所以申报两个属性
@property (nonatomic, strong) MPMoviePlayerController *playerCtrl; 

@property (nonatomic, strong) UIImageView *previewImage; 
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 

    [self setupMovie]; 
    } 

    -(void)setupMovie 
    { 
     NSString *moviePath = [[NSBundle mainBundle] pathForResource:@"video_name" ofType:@"type_of_video"]; 
     NSURL *movieURL = [NSURL fileURLWithPath:moviePath]; 

     self.playerCtrl = [[MPMoviePlayerController alloc] initWithContentURL:movieURL]; 
     self.playerCtrl.scalingMode = MPMovieScalingModeAspectFill; 
     self.playerCtrl.controlStyle = MPMovieControlStyleNone; 
     self.playerCtrl.view.frame = self.window.frame; 

     [[NSNotificationCenter defaultCenter] addObserver:self 
               selector:@selector(moviePlayBackDidFinish:) 
                name:MPMoviePlayerPlaybackDidFinishNotification object:nil]; 

     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayerPlaybackStateDidChange:) name:MPMediaPlaybackIsPreparedToPlayDidChangeNotification object:nil]; 

     [self.window addSubview:self.playerCtrl.view]; 
     [self.playerCtrl prepareToPlay]; 

     self.previewImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"SplashScreen"]]; 
     self.previewImage.frame = self.window.frame; 
     self.previewImage.contentMode = UIViewContentModeScaleAspectFill; 
     [self.window addSubview:self.previewImage]; 


    } 

    - (void)moviePlayBackDidFinish:(MPMoviePlayerController *)player 
    { 
     [self stopPlayingVideo]; 
    } 

    - (void)moviePlayerPlaybackStateDidChange:(NSNotification*)notification 
    { 
     if (self.playerCtrl.isPreparedToPlay) { 
      [self.previewImage removeFromSuperview]; 
      [self.playerCtrl play]; 
     } 
    } 

    - (void)stopPlayingVideo 
    { 
     @weakify(self) 
     [UIView animateWithDuration:2.3 animations:^(void) { 
      @strongify(self) 
      [self.playerCtrl.view setAlpha:0.0]; 
     } completion:^(BOOL finished) { 
      @strongify(self) 
      [self.playerCtrl.view removeFromSuperview]; 

     }]; 

    } 

第二个解决方案,如果你想在代码中所有的动画:

  1. 设置闪屏图像作为第一帧你的gif动画 2.创建视图控制器所有需要的动画,并从你的第一个视图控制器在naviga重刑层次(如果你不想模态控制器初始化这个VC为根的导航控制器) - 当您使用的TabBar作为根控制器
  2. 显示所有动画
  3. 只需dissmis控制器的所有存根改完之后,这可能是有帮助