Created
February 27, 2012 20:19
-
-
Save MaxGabriel/1926754 to your computer and use it in GitHub Desktop.
Set photo for UIScrollView
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)viewDidLoad | |
{ | |
[super viewDidLoad]; | |
self.title = _photoName; | |
_imageView.image = _image; | |
_imageView.frame = (CGRect){CGPointZero, _imageView.image.size}; | |
_scroller.contentSize = _imageView.image.size; | |
_scroller.minimumZoomScale = .3; | |
_scroller.maximumZoomScale = 3; | |
_scroller.delegate = self; | |
_scroller.scrollEnabled = YES; | |
[_scroller setBackgroundColor:[UIColor blackColor]]; | |
[_scroller addSubview:_imageView]; | |
CGFloat width = _imageView.image.size.width; | |
CGFloat height = _imageView.image.size.height; | |
CGRect rect; | |
if (width > height) { | |
rect = CGRectMake(0, 0, 1, height+150); | |
} else { | |
rect = CGRectMake(0, 0, width, 1); | |
} | |
[_scroller zoomToRect:rect animated:NO]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment