我正在创建一个带有默认图像的 PFImageView。然后我在后台加载图像,当图像完成从服务器下载后,它会立即显示并替换占位符/默认图像。问题是从默认图像到下载图像的过渡不是很愉快。有没有办法创建淡出默认并淡入下载的动画?
这是我的代码。
// set the pfImageView into the webView
_pfImageView = [[PFImageView alloc] initWithImage:[UIImage imageNamed:[NSString stringWithFormat:@"%dpTall.jpg", [self.drink.glassId intValue]]]];
_pfImageView.frame = CGRectMake(244, 0, 76, 114);
[webView.scrollView addSubview:_pfImageView];
// create a query for finding images on Parse
PFQuery *query = [PFQuery queryWithClassName:@"Images"];
[query whereKey:@"drinkId" equalTo:[NSNumber numberWithInt:self.drink.primaryKey]];
[query getFirstObjectInBackgroundWithBlock:^(PFObject *object, NSError *error) {
if (!error) {
PFFile *imageFile = [object objectForKey:@"image"];
_pfImageView.file = imageFile;
[_pfImageView loadInBackground];
} else {
NSLog(@"PFQuery Error:%@", [error localizedDescription]);
}
}];
谢谢