如何在UITableView單元中加載圖像,並在加載圖像時使用淡入效果?在UITableView單元內,我怎樣才能淡入淡入的圖像?
回答
您正在嘗試異步圖像。有一個在提供一個偉大的文章:http://www.markj.net/iphone-asynchronous-table-image/
內connectionDidFInishLoading只是把在此之後
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];
SDImageWeb是一個相當不錯的庫,它做什麼你需要。它甚至具有圖像緩存,所以一旦下載圖像,下次從本地閃存中選取它們。
這是什麼不能做的是fadeIn
效果。但這很容易添加,動畫爲UIView
。
所以異步下載圖像, [imageView setImageWithURL:[NSURL URLWithString:@"http://www.domain.com/path/to/image.jpg"]];
多數民衆贊成..
要淡入動畫放。
- (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效果嗎?當用戶滾動並查看其他UIImageViews時,我會使用淡入效果來顯示圖像。 –
查看我的更新代碼fadein animaiton ... –
- 1. 我們怎樣才能給一個簡單的滑塊淡入淡出效果?
- 2. 我怎樣才能讓我的整個網站模糊,淡入淡出?
- 3. 淡入淡出背景圖像淡入淡出div內容
- 4. 淡出/淡入圖像在元素
- 5. 我怎樣才能淡入淡出出現(使用.bind命令的列表?
- 6. 我怎樣才能使這個淡入淡出成爲幻燈片?
- 7. 簡單的jQuery淡入淡出圖像
- 8. 淡入淡出的圖像
- 9. 淡入淡出圖像進入UITableView編輯模式?
- 10. Javascript淡入淡出圖像
- 11. 圖像淡入淡出
- 12. android圖像淡入淡出
- 13. Javascript - 淡入淡出圖像?
- 14. 淡入淡出圖像?
- 15. jquery淡入/淡出圖像
- 16. Javascript圖像淡入淡出?
- 17. jquery淡入淡出div中的背景圖像 - 淡入淡出
- 18. 淡入圖像,淡出出圖像
- 19. 爲什麼我的圖像不能淡入淡出?
- 20. 在背景圖像中淡入淡出
- 21. 圖像在畫面上淡入淡出
- 22. 我怎麼能在淡入/淡出數組中添加延遲
- 23. 淡入和圖像
- 24. 使圖像淡入
- 25. Android淡入圖像
- 26. CSS淡入圖像
- 27. UITableView淡入背景
- 28. 淡入淡出的圖像javascript
- 29. 淡入淡出中的背景圖像
- 30. 具有淡入淡出圖像的CSS
謝謝,但我需要淡入效果。 –
評論已經更新。 –
謝謝哥們:) – Abo3atef