开发者

ipad: present a view with zoom out effect and remove with zoom in effect

I want to display a view with zoom out effect on click of a button and dissolve the view with a zoom in effect can y开发者_如何学编程ou guide me to achieve this.

Thanx in advance


You can do it with a CAAnimation to the view's layer:

CABasicAnimation *ani = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
[ani setDuration:0.5];
[ani setRepeatCount:1];
[ani setFromValue:[NSNumber numberWithFloat:1.0]];
[ani setToValue:[NSNumber numberWithFloat:0.1]];
[ani setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
[[myView layer] addAnimation:ani forKey:@"zoom"];

This adds an animation that makes the view shrink into its center. You might want to add set a delegate and implement animationDidStop:finished: in which you then hide the view and reset the layer's scale (see CAAnimation reference).

To create the opposite effect simply exchange the from and to values.

Also note that while the scale is not 1.0, the frame property is undefined. That is, if you try to move it or change its size while the layer's scale is not 1.0, strange things will happen.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜