From f095d379fe2cc22c28922adc037ceacc523fa104 Mon Sep 17 00:00:00 2001 From: Ben Guild Date: Tue, 3 Apr 2018 18:04:28 +0900 Subject: [PATCH] Adding a subtle crossfade when transitioning `NYTScalingImageView` between placeholder and image. I noticed especially with differing aspect ratios that this was a fairly jarring transition. --- NYTPhotoViewer/NYTScalingImageView.m | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/NYTPhotoViewer/NYTScalingImageView.m b/NYTPhotoViewer/NYTScalingImageView.m index 596d089c..e58081bb 100644 --- a/NYTPhotoViewer/NYTScalingImageView.m +++ b/NYTPhotoViewer/NYTScalingImageView.m @@ -118,8 +118,11 @@ - (void)updateImage:(UIImage *)image imageData:(NSData *)imageData { // Remove any transform currently applied by the scroll view zooming. self.imageView.transform = CGAffineTransformIdentity; - self.imageView.image = imageToUse; - + + [UIView transitionWithView:self.imageView duration:0.15f options:UIViewAnimationOptionTransitionCrossDissolve animations:^{ + self.imageView.image = imageToUse; + } completion:nil]; + #ifdef ANIMATED_GIF_SUPPORT // It's necessarry to first assign the UIImage so calulations for layout go right (see above) self.imageView.animatedImage = [[FLAnimatedImage alloc] initWithAnimatedGIFData:imageData];