Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding a subtle crossfade when transitioning NYTScalingImageView between placeholder and image. #261

Open
wants to merge 16 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Changes for users of the library currently on `develop`:
- A data source no longer has to handle out-of-bounds indexes ([#227](https://github.com/NYTimes/NYTPhotoViewer/pull/227))
- The data source is not retained ([#227](https://github.com/NYTimes/NYTPhotoViewer/pull/227))
- Respect safe areas for iOS 11 support
- Adding a subtle crossfade when transitioning `NYTScalingImageView` between placeholder and image.

## [1.2.0](https://github.com/NYTimes/NYTPhotoViewer/releases/tag/1.2.0)

Expand Down
7 changes: 5 additions & 2 deletions NYTPhotoViewer/NYTScalingImageView.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down