2010-08-16 86 views
0

缩放图像我怎样才能得到,当它由用户缩放图像大小, 我写下这些在我的项目:获取图像大小时,由用户

- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView 
{ 
return imageView; 
} 
-(void) didLoad{ 
UIImageView *tempImageView = [[UIImageView alloc] initWithImage:[UIImage  imageNamed:@"image.jpg"]]; 
self.imageView = tempImageView; 
[tempImageView release]; 

scrollMapView.contentSize = CGSizeMake(imageView.frame.size.width, imageView.frame.size.height); 
scrollMapView.maximumZoomScale = 4.0; 
scrollMapView.minimumZoomScale = 0.75; 
scrollMapView.clipsToBounds = YES; 
scrollMapView.delegate = self; 
[scrollMapView addSubview:imageView]; 
} 

我只是想知道图像大小时,放大.. 谢谢。

+0

你的意思是,如果一个200x400的图像以2倍显示,你想要的东西,返回400x800? – Vegar 2010-08-17 07:04:33

+0

是啊,类似的东西..顺便说一句,我已经得到了.. thnx兄弟.. :) – 2011-06-20 03:15:17

回答

3

也许你可以这样做:

newZoomedWidth = scrollView.zoomScale * imageView.frame.size.width 
1

我可能是错误的(我不是iPhone开发者),但我不认为图像本身得到放大;它只是缩放图像视图的滚动视图的显示。所以,它只是滚动视图的一个属性发生了变化;图像保持不变。

这意味着你应该能够只需get the image view's imageask that for its size

如果您想要图像的缩放大小而不是其原始大小,请获取其原始大小并将两个维度乘以the scroll view's zoom scale