Iphone 如何缩放滚动中的图像?

Iphone 如何缩放滚动中的图像?,iphone,Iphone,我想做一个动画,我在滚动视图中有不同的图像。我想当一个图像进入中心时,它应该像Net-a-porter杂志应用程序中的动画一样缩放 有人能帮我吗?您可以尝试使用zoomScale属性或-zoomToRect:animated:方法 如果要使用zoomScale请注意使用UIViewAnimation更改动画块内的比例,您可以尝试使用zoomScale属性或-zoomToRect:animated:方法 如果要使用zoomScale请注意使用UIViewAnimation更改动画块内的比例,请使用

我想做一个动画,我在滚动视图中有不同的图像。我想当一个图像进入中心时,它应该像Net-a-porter杂志应用程序中的动画一样缩放


有人能帮我吗?

您可以尝试使用
zoomScale
属性或
-zoomToRect:animated:
方法


如果要使用
zoomScale
请注意使用
UIViewAnimation
更改
动画
块内的比例,您可以尝试使用
zoomScale
属性或
-zoomToRect:animated:
方法


如果要使用
zoomScale
请注意使用
UIViewAnimation
更改
动画
块内的比例,请使用滚动视图委托查看要缩放的图像视图

- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView { CGPoint pt= scrollView.contentOffset; CGSize content_size=,scrollView.contentSize; //find out image to be zoomed and call animateCurrentImage } -(无效)ScrollViewDiEndDecelling:(UIScrollView*)scrollView { CGPoint pt=scrollView.contentOffset; CGSize content_size=,scrollView.contentSize; //找到要缩放的图像并调用animateCurrentImage } 在中间设置图像动画,注意imageview

- (void)animateCurrentImage:(UIImageView *)currentImage { if(prevImage) { [UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:1]; prevImage.transform=CGAffineTransformIdentity; [UIView commitAnimations]; } [UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:1]; currentImage.transform=CGAffineTransformMakeScale(1.2, 1.2); [UIView commitAnimations]; [self notePreviousImage:currentImage]; } - (void)notePreviousImage:(UIImageView *)currentImage { prevImage=currentImage; [prevImage retain]; //only if required } -(无效)动画当前图像:(UIImageView*)当前图像{ 如果(前置图像) { [UIView beginAnimations:nil上下文:NULL]; [UIView setAnimationDuration:1]; prevImage.transform=CGAffineTransformity; [UIView委员会]; } [UIView beginAnimations:nil上下文:NULL]; [UIView setAnimationDuration:1]; currentImage.transform=CGAffineTransformMakeScale(1.2,1.2); [UIView委员会]; [self-notePreviousImage:currentImage]; } -(void)notePreviousImage:(UIImageView*)currentImage { prevImage=当前图像; [prevImage retain];//仅当需要时 }
使用“滚动视图委托”可确定要缩放的图像视图

- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView { CGPoint pt= scrollView.contentOffset; CGSize content_size=,scrollView.contentSize; //find out image to be zoomed and call animateCurrentImage } -(无效)ScrollViewDiEndDecelling:(UIScrollView*)scrollView { CGPoint pt=scrollView.contentOffset; CGSize content_size=,scrollView.contentSize; //找到要缩放的图像并调用animateCurrentImage } 在中间设置图像动画,注意imageview

- (void)animateCurrentImage:(UIImageView *)currentImage { if(prevImage) { [UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:1]; prevImage.transform=CGAffineTransformIdentity; [UIView commitAnimations]; } [UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:1]; currentImage.transform=CGAffineTransformMakeScale(1.2, 1.2); [UIView commitAnimations]; [self notePreviousImage:currentImage]; } - (void)notePreviousImage:(UIImageView *)currentImage { prevImage=currentImage; [prevImage retain]; //only if required } -(无效)动画当前图像:(UIImageView*)当前图像{ 如果(前置图像) { [UIView beginAnimations:nil上下文:NULL]; [UIView setAnimationDuration:1]; prevImage.transform=CGAffineTransformity; [UIView委员会]; } [UIView beginAnimations:nil上下文:NULL]; [UIView setAnimationDuration:1]; currentImage.transform=CGAffineTransformMakeScale(1.2,1.2); [UIView委员会]; [self-notePreviousImage:currentImage]; } -(void)notePreviousImage:(UIImageView*)currentImage { prevImage=当前图像; [prevImage retain];//仅当需要时 }