这就是我成功使用SDWebImageManager下载图像的方法:
- (void) downloadThumbnails:(NSURL *) finalUrl
{
SDWebImageManager *manager = [SDWebImageManager sharedManager];
[manager downloadWithURL:finalUrl
options:0
progress:nil
completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished) {
if (image)
{
self.thumbnailURL = [finalUrl absoluteString];
}
}];
}
- (UIImage*)thumbnail {
if (!self.thumbnailURL) return nil;
return [[SDImageCache sharedImageCache] imageFromDiskCacheForKey:self.thumbnailURL];
}
如何修改以产生交叉淡入淡出效果?交叉渐变效果是使图像显示转换缓慢的效果,就像TechCrunch iOS应用程序一样。谢谢!
更新:如果我可以在uitableview单元格中执行任何其他操作以获得交叉淡入淡出效果(除了SDWebImage),您可以在答案中将其写入。
更新:我上次更新后收到的答案很少,我可以部分解决问题。使用transitionWithView,如下面的答案,它正在工作和交叉淡入我想要的方式但由于我使用的tableivew控制器在接触底部时加载更多条目,它会在新条目块之前刷新所有单元格一次加载,我该如何防止这种行为?
答案 0 :(得分:4)
看起来您在不同的文件中使用SDWebImageManager,该文件必然不是UITableViewController类。如果它位于不同的类中,您可以直接使用transitionWithView但不能直接使用SDWebImageManager。
但是在您的表视图控制器类中,您正在使用cellForRowAtIndexPath并将图像与UITableViewCell的imageView链接,您可以使用transitionView,如下所示:
[UIView transitionWithView:cell.(Your Image View)
duration:0.5
options:UIViewAnimationOptionTransitionCrossDissolve
animations:^{
cell.(Your ImageView).image = [(how ever you are calling it)];
} completion:^(BOOL finished) {
// Optionally you can do anything after the completion
}];
希望这有帮助!
答案 1 :(得分:1)
您可以使用UIView transitionWithView:duration:options:animations:completion:
方法将图像视图从旧图像交叉溶解到新图像,如下所示:
[UIView transitionWithView:imageView
duration:0.4
options:UIViewAnimationOptionTransitionCrossDissolve
animations:^{
// Set the new image
// Since its done in the animation block, the change will be animated
imageView.image = newImage;
} completion:^(BOOL finished) {
// Do whatever when the animation is finished
}];
只需在completed
区块中使用此代码,您通常会将图片设置为imageView
答案 2 :(得分:-1)
请参阅界面定义:
- (id<SDWebImageOperation>)downloadWithURL:(NSURL *)url
options:(SDWebImageOptions)options
progress:(SDWebImageDownloaderProgressBlock)progressBlock
completed:(SDWebImageCompletedWithFinishedBlock)completedBlock;
SDImageOptions有几个值,我认为这个是您的期望:
/**
* This flag enables progressive download, the image is displayed progressively during download as a browser would do.
* By default, the image is only displayed once completely downloaded.
*/
SDWebImageProgressiveDownload = 1 << 3