I want to do an animation in which i have different images in scroll view.I want that when an image comes in center it should zoom like an anim开发者_Go百科ation done in Net-a-porter magazine app...
Can anyone help me??
Use scroll view delegate to find out which imageview to be zoomed.
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView { CGPoint pt= scrollView.contentOffset; CGSize content_size=,scrollView.contentSize; //find out image to be zoomed and call animateCurrentImage }
Animate the image in the center note that 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 }
You can try using the zoomScale
property, or the -zoomToRect:animated:
method.
If you want to use zoomScale
pls note to change the scale within an animation
block using UIViewAnimation
.
精彩评论