2016-07-18 9 views
0

アニメーションのロゴを使用してアプリを起動したいと考えています。私が理解しているところでは、カスタム・クラスを許可しないが、リソースの使用を許可する初期ビューにアクセスできます。iOS起動画面のアニメーション化への最適なアプローチ

私は助けをここにこの答えを読んだ:How to Play a mp4 Video on the launch screen when the app loads Xcode SWIFT

はどちらのアプローチより良い、なぜでしょうか?最初の打ち上げビューから

  1. セグエ、そしてスウィフトにロゴを自分自身をアニメーション:

    まず、私はロゴの静止画像で起動します。

  2. 最初の起動ビューから継承し、AVPlayerを使用して、アニメーションされているロゴのビデオ(またはGIF)を再生します。

静的な起動ロゴ画像からアニメーション化されたロゴへとシームレスに移行したいと考えています。

答えて

0

アニメーションが短ければオプション1、それほど複雑ではありません。アニメーションが長い場合はオプション2、それ以外の場合はメモリが多すぎます。

オプション1は非常に簡単です:

イムは、あなたがストーリーボードを使用していると仮定します。したがって、新しいView Controller(LogoAnimationViewControllerなど)を作成し、ストーリーボードの初期View Controllerとして設定します。 viewDidLoadでは、これを行います:

UIImage *animationImage = [UIImage animatedImageNamed:@"logo-animation" duration:1]; 
UIImageView *animationImageView = [[UIImageView alloc] initWithImage:animationImage]; 
animationImageView.contentMode = UIViewContentModeScaleAspectFit; 
animationImageView.center = CGPointMake(CGRectGetMidX(self.view.bounds), CGRectGetMidY(self.view.bounds)); 
[self.view addSubview:animationImageView]; 

dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ 
    UIViewController *viewController = [self.storyboard instantiateViewControllerWithIdentifier:@"ViewController"]; // put whatever view controller you wanna show after the animation here 
    [self presentViewController:viewController animated:YES completion:nil]; 
}); 

起動画像から初期表示コントローラへの移行は、デフォルトでスムーズにクロスフェードされます。

関連する問題