2016-07-15 192 views

回答

0

添加GIF您可以選擇查看器一樣閃屏,其停留3-4秒。無法啓動圖像gif。

1)你可以通過逐個播放圖像序列來完成。 UIImageView類中有可用的方法來播放圖像數組。

2)你可以播放5秒的視頻。

編輯

NSArray *animationArray=[NSArray arrayWithObjects: 
             [UIImage imageNamed:@"images.jpg"], 
              [UIImage imageNamed:@"images1.jpg"], 
              [UIImage imageNamed:@"images5.jpg"], 
             [UIImage imageNamed:@"index3.jpg"], 
         nil]; 
    UIImageView *animationView=[[UIImageView alloc]initWithFrame:CGRectMake(0, 0,320, 460)]; 
     animationView.backgroundColor=[UIColor purpleColor]; 
     animationView.animationImages=animationArray; 
     animationView.animationDuration=1.5; 
    animationView.animationRepeatCount=0; 
     [animationView startAnimating]; 
     [self.view addSubview:animationView]; 
+0

怎麼樣?你可以給我發送代碼或例子 –

+0

最好的方法是播放3-4秒的視頻,並且一旦視頻播放完成就移動到下一個視圖控制器。所以你必須在你的rootview控制器裏播放視頻。 –

+0

我嘗試相同的代碼,但首先顯示白色閃屏然後顯示動畫 –

0

這可以幫助你:

NSMutableArray *images = [[NSMutableArray alloc] init]; 
NSInteger animationImageCount = 38; 
for (int i = 0; i < animationImageCount; i++) { 
    // Images are numbered IndexedImagesInMyAnimation0, 1, 2, etc... 
    [images addObject:(id)[UIImage imageNamed:[NSString stringWithFormat:@"IndexedImagesInMyAnimation%d", i]].CGImage]; 
} 

CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"contents"]; 
animation.calculationMode = kCAAnimationDiscrete; 
animation.duration = animationImageCount/24.0; // 24 frames per second 
animation.values = images; 
animation.repeatCount = 1; 
animation.removedOnCompletion = NO; 
animation.fillMode = kCAFillModeForwards; 
[self.animationImageView.layer addAnimation:animation forKey:@"animation"]; 

而且你也知道的repeatCount和單週期動畫的時間,你可以很容易地計算出總的動畫時間是這樣的:

totalAnimationTime = repeatCount *持續時間

現在,您可以在計時器中使用這個totalAnimationTime並切換視圖控制器。

+0

我嘗試了相同的代碼,但首先顯示白色閃屏然後顯示動畫 –

+0

我相信你有本地圖像。如果是,那麼你可以在UIImageView中使用第一個圖像作爲默認圖像。 –

0

按照蘋果的指導方針,不可能使用gif作爲閃屏或啓動圖像。

如果您正在使用故事板作爲啓動屏幕(> ios 7),那麼您可以使用jpg但低於或等於ios 7的版本,您只有選項png

您可以通過你的第一個視圖控制器動畫實現動畫樣啓動,並使其作爲碎石飛濺工作。在這種情況下,你不應該設置啓動畫面故事板的任何啓動畫面(或者設置黑色背景顏色),所以當應用程序啓動時它會顯示一秒黑屏,然後你的第一個視圖控制器將變成動畫,你的應用程序將會得到啓動動畫或gif

希望這將有助於:)