I am trying to figure out if this is possible or not. I have a UIScrollView
in my UIViewController
(the same size as the screen) the set content size is 640*640. The UIView
in the scroll view, size 640
*640. Code :
#import "ViewController.h"
@interface ViewController () <UIScrollViewDelegate>
@property (weak, nonatomic) IBOutlet UIScrollView *scrollView;
@property (strong, nonatomic) UIView *viewForZoom;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
//self.profileImageView.layer.cornerRadius = self.profileImageView.frame.size.width / 2;
//self.profileImageView.clipsToBounds = YES;
UIView *content = [[[NSBundle mainBundle] loadNibNamed:@"floatingView" owner:self options:nil] objectAtIndex:0];
self.viewForZoom=content; //need this pointer for the zoom
self.scrollView.contentSize=CGSizeMake(640 ,640);
self.scrollView.minimumZoomScale=0.25;
self.scrollView.maximumZoomScale=1;
[self.scrollView addSubview:content];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView {
return self.viewForZoom;
}
This zooms and pans as expected :
When fully zoomed out the view is stuck to the top left on the screen. What I want to happen is as the view zooms out is sticks to the centre of the screen but it can also be dragged around within the 640*640 container. Is this something that is possible? Any help would be appreciated. Thanks