开发者

How to animate the objects in iphone sdk?

I'm开发者_StackOverflow中文版 using UIImageViews. I'd like this behaviour: if we touch the UIImageView it needs to zoom double and if the user remove his finger set the UIImageView to the actual position of the finger... How can I do?

Can any one please tell me the code for this?

Thanks in advance


U can use UIScrollView for this, with UIImageView as a sub-view of the scroll view.

For this, U need to sub-class UIScrollView to write a custom scroll view. It will have all the properties of UIScrollView. Only thing, U have to override touchesEnded: method, which will notify the superview. So in the superview, again u can set the zoomscale to 1, to make it to actual position.


implement the delegate methods touchesBegan:withEvent: and – touchesEnded:withEvent:

in touches began method change the frame of the imageview to double the size of the imageview and in touchesEnded change the frame to the original size.

while declaring the image enable user interaction on it

 UIImageView *imageview=[[UIImageView alloc] init];
    imageview.userInteractionEnabled=YES;


- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
imageview.frame=CGRectMake(0,0,20,20);
}

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
imageview.frame=CGRectMake(0,0,40,40);
}

TNX

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜