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

Fix orientation issue with reference view of type UIImageView #116

Merged
merged 1 commit into from
Jan 26, 2016
Merged
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
35 changes: 22 additions & 13 deletions Pod/Classes/ios/NYTPhotoTransitionAnimator.m
Original file line number Diff line number Diff line change
Expand Up @@ -227,19 +227,28 @@ + (UIView *)newAnimationViewFromView:(UIView *)view {

UIView *animationView;

if (view.layer.contents) {
animationView = [[UIView alloc] initWithFrame:view.frame];
animationView.layer.contents = view.layer.contents;
animationView.layer.bounds = view.layer.bounds;
animationView.layer.cornerRadius = view.layer.cornerRadius;
animationView.layer.masksToBounds = view.layer.masksToBounds;
animationView.contentMode = view.contentMode;
animationView.transform = view.transform;
}
else {
animationView = [view snapshotViewAfterScreenUpdates:YES];
}

if (view.layer.contents) {
if ([view isKindOfClass:[UIImageView class]]) {
// The case of UIImageView is handled separately since the mere layer's contents (i.e. CGImage in this case) doesn't
// seem to contain proper informations about the image orientation for portrait images taken directly on the device.
animationView = [(UIImageView *)[[view class] alloc] initWithImage:((UIImageView *)view).image];
animationView.bounds = view.bounds;
}
else {
animationView = [[UIView alloc] initWithFrame:view.frame];
animationView.layer.contents = view.layer.contents;
animationView.layer.bounds = view.layer.bounds;
}

animationView.layer.cornerRadius = view.layer.cornerRadius;
animationView.layer.masksToBounds = view.layer.masksToBounds;
animationView.contentMode = view.contentMode;
animationView.transform = view.transform;
}
else {
animationView = [view snapshotViewAfterScreenUpdates:YES];
}

return animationView;
}

Expand Down