2011-10-25 9 views

答えて

2

あなたは非同期画像に興味を持っています。

//Paste following here 
imageView.alpha = 0.0f; 
[UIView beginAnimations:nil context:NULL]; 
[UIView setAnimationDuration:0.5f]; 

imageView.alpha = 1.0f; 

[UIView commitAnimations]; 
+0

ありがとうございますが、効果が消えていく必要があります。 –

+0

コメントが更新されました。 –

+0

ありがとうございました:) – Abo3atef

5

SDImageWebは何をしてかなり良いライブラリです:connectionDidFInishLoading以内http://www.markj.net/iphone-asynchronous-table-image/

だけでそれをフェードインするために、この

UIImageView* imageView = [[[UIImageView alloc] initWithImage:[UIImage imageWithData:data]] autorelease]; 
//Paste below code here 

後、後をつけ:で利用できる素晴らしい記事がありますあなたが必要です。それはイメージキャッシュを持っているので、イメージがダウンロードされると、次にローカルフラッシュメモリからピックされます。

これは、fadeIn効果です。しかし、これは、UIViewのアニメーションではかなり簡単に追加できます。だから、非同期的にアニメーションをフェードインに置くために..

すべてのthats [imageView setImageWithURL:[NSURL URLWithString:@"http://www.domain.com/path/to/image.jpg"]];

を画像をダウンロードするには

[self fadeInLayer: imageView.layer];

これはトリックを行う必要があります - これを呼び出すことが

- (void)fadeInLayer:(CALayer *)l 
{ 
    CABasicAnimation *fadeInAnimate = [CABasicAnimation animationWithKeyPath:@"opacity"]; 
    fadeInAnimate.duration   = 0.5; 
    fadeInAnimate.repeatCount   = 1; 
    fadeInAnimate.autoreverses  = NO; 
    fadeInAnimate.fromValue   = [NSNumber numberWithFloat:0.0]; 
    fadeInAnimate.toValue    = [NSNumber numberWithFloat:1.0]; 
    fadeInAnimate.removedOnCompletion = YES; 
    [l addAnimation:fadeInAnimate forKey:@"animateOpacity"]; 
    return; 
} 

。これは0.5秒でアルファ0から1にイメージをアニメーション化します!アニメーションの素晴らしいフェードを与えるために。

+0

ありがとうございました。プログラムでfadeInエフェクトを追加する方法を教えてください。ユーザーがスクロールして他のUIImageViewsを見ると、画像が表示されるfadeInエフェクトになります。 –

+0

fadein animaitonのための私の更新されたコードを見てください... –

関連する問題