2009-03-19 10 views

答えて

28

あなたは画像のセリエAを持っている場合は、あなたをアニメーション化するには、簡単にUIImageViewでそれを行うことができます。

UIImage *blur5 = [UIImage imageNamed:@"blur5.png"]; 
UIImage *blur6 = [UIImage imageNamed:@"blur6.png"]; 

self.imageView.animationImages = [[NSArray alloc] initWithObjects:blur5, blur6, nil]; 
self.imageView.animationRepeatCount = 5; 
[self.imageView startAnimating]; 

私はのUIWebViewを使用しようとするよりも、これは簡単に見つかりました。

+15

をこれは、アニメーションを表示するには、正しい解決策であります画像。しかし、これは質問に対する正解ではありません。 – Satyam

7

UIWebViewはすべてのGIFコンテンツを正しく表示しません。 UIImageViewを使用する必要がありますが、iPhone OSはアニメーションGIFSをサポートせず、最初のフレームのみを表示します。

したがって、最初に他のフレームをすべて抽出する必要があります。ここ

原油のコード例: http://pliep.nl/blog/2009/04/iphone_developer_decoding_an_animated_gif_image_in_objc

1

もう一つの選択肢は、アプリケーションでのGIFをデコードすることであり、その後、OpenGLのオブジェクトに「フレームが仕えます」。この方法では、大きなgifのメモリが不足する可能性は低くなります。

+1

これを行う方法の例がありますか? –

3

これは、コードのこの部分によって達成することができます。

NSArray * imageArray = [[NSArray alloc] initWithObjects:[UIImage imageNamed:@"1.png"], [UIImage imageNamed:@"2.png"], nil]; //this will be the frames of animation images in sequence. 
ringImage = [[UIImageView alloc]initWithFrame:CGRectMake(100,200,600,600)]; 
ringImage.animationImages = imageArray; 
ringImage.animationDuration = 1.5;//this the animating speed which you can modify 
ringImage.contentMode = UIViewContentModeScaleAspectFill; 
[ringImage startAnimating];//this method actually does the work of animating your frames. 

私はその昔thread..butが誰かのために役立つかもしれない知っている... :)

関連する問題