Maintain zoom scale when image is rotated inside UIScrollView
I have an image inside a ScrollView. It allows for pinch and zoom. It is also possible to rotate the image inside the ScrollView to a custom degree. When I do that, I lose the current zoom level of the image, and it reverts back to its 100% zoom and rotates. Is there a way I can maintain the zoom level while rotating the image?
I am doing this at the moment:
UIScrollView* mainScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 80,
self.view.frame.size.width, self.view.frame.size.height )];
self.pictureView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Image1.png"]];
[mainScrollView setContentSize:CGSizeMake//(620,612)];
(self.pictureView.frame.size.width, self.pictureView.frame.size.heigh开发者_Python百科t)];
[mainScrollView addSubview:self.pictureView];
mainScrollView.minimumZoomScale = 0.5;
mainScrollView.maximumZoomScale = 6.0;
mainScrollView.delegate = self;
[mainScrollView setScrollEnabled:YES];
[self.view addSubview:mainScrollView];
[mainScrollView release];
-(void) rotatePicture:(float) value{
self.pictureView.transform = CGAffineTransformMakeRotation(value );
}
Did you try:
-(void) rotatePicture:(float) value{
self.pictureView.transform = CGAffineTransform CGAffineTransformRotate (self.pictureView.transform, value);
}
What this does is to preserve the zoom transform on the pictureView, and adds a rotate on top of it.
精彩评论