Eilon
Eilon

Reputation: 2982

Making an image go full screen like in photos app

how can you make a UIImage go full screen, but not the actual frame of the image, but like the photos in the iOS photos app, where you tap a photo and it goes to a special full screen mode, where you can zoom in etc. many thanks!

Upvotes: 1

Views: 1414

Answers (1)

Tommy Devoy
Tommy Devoy

Reputation: 13549

Add a UIImageView as subview to a UIScrollView with it's frame equal to the size of the screen.

Set your UIScrollViewDelegate and implement the delegate method:

- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView {
    return self.yourImageView;
}

Attach two tap gesture recognizers to the imageView:

  • Single tap recognizer -> for zooming back to normal frame
  • Double tap recognizer -> for zooming in rapidly to specific spot

Implement your tapGestureRecognizer selectors and direct the zoom logic using:

CGPoint location = [tapRecognizer locationInView:self.yourImageView]; // Location of tap

and

[self.scrollView zoomToRect:whateverRect animated:YES]; //Zooming in/out to locations
[self.scrollView setZoomScale:whateverScale animated:YES];

Upvotes: 1

Related Questions