Iphone 在UITableView单元中,如何延迟加载淡入的图像?
如何在UITableView单元格中延迟加载图像,并在加载图像时产生淡入效果?您使用的是异步图像。有一篇很棒的文章可以在以下网站上找到: 在ConnectionIDFinishLoading中,将后面的放在后面Iphone 在UITableView单元中,如何延迟加载淡入的图像?,iphone,objective-c,ios,Iphone,Objective C,Ios,如何在UITableView单元格中延迟加载图像,并在加载图像时产生淡入效果?您使用的是异步图像。有一篇很棒的文章可以在以下网站上找到: 在ConnectionIDFinishLoading中,将后面的放在后面 UIImageView* imageView = [[[UIImageView alloc] initWithImage:[UIImage imageWithData:data]] autorelease]; //Paste below code here 要淡入,请执行以下操作: /
UIImageView* imageView = [[[UIImageView alloc] initWithImage:[UIImage imageWithData:data]] autorelease];
//Paste below code here
要淡入,请执行以下操作:
//Paste following here
imageView.alpha = 0.0f;
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5f];
imageView.alpha = 1.0f;
[UIView commitAnimations];
这是一个很好的图书馆,可以满足你的需要。它甚至还有图像缓存,所以一旦下载了图像,下次就可以从本地闪存中提取
这不起作用的是fadeIn
效果。但这很容易添加,使用UIView
动画
因此,要异步下载图像,
[imageView setImageWithURL:[NSURL URLWithString:@]http://www.domain.com/path/to/image.jpg"]];代码>
就这些
加入fadein动画
- (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;
}
调用此-[self-fadeInLayer:imageView.layer]代码>
这应该能奏效。这将使您的图像在0.5秒内从alpha 0变为1!为您提供精彩的淡入动画。谢谢您,伙计。您能告诉我如何以编程方式添加fadeIn效果吗?当用户滚动并看到其他UIImageView时,我会为图像显示淡入效果。谢谢,但我需要淡入效果。