当图像在 UIScrollView 内旋转时保持缩放比例
我在 ScrollView 中有一个图像。它允许捏合和缩放。还可以将 ScrollView 内的图像旋转到自定义角度。当我这样做时,我会丢失图像的当前缩放级别,并且它会恢复到 100% 缩放并旋转。有没有办法在旋转图像时保持缩放级别?
我现在正在这样做:
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.height)];
[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 );
}
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.height)];
[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 );
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您尝试过吗:
它的作用是保留图片视图上的缩放变换,并在其顶部添加旋转。
Did you try:
What this does is to preserve the zoom transform on the pictureView, and adds a rotate on top of it.