开发者

iPhone animated view overlay

I have a few XIBs that are my pages, and i'm using presentmodalviewcontroller to switch between them with some buttons. Now I want to use other buttons to pull up overlays on those views. How I have it now is I have a button which simply toggles the "Hidden" property on the UIImageview.

What are options for animating the show/hide functionality of this? I'd like some sort of zoom-in or zoom-out effect when the overlay is called up rather than just suddenly showing/hiding.

-(IBAction)basketballbutton{
if (basketb开发者_如何学Pythonall.hidden == YES)
    basketball.hidden = NO;
else if (basketball.hidden == NO)
    basketball.hidden = YES;

Thanks!


You can animate the view opacity using the alpha property.

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5f];
[basketball setAlpha:([basketball alpha] > 0.0) ? 0.0f : 1.0f];
[UIView commitAnimations];

This will animate the showing and hiding of the view.

Here is how you set the transform for scaling:

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5f];
// Scale up 2x
[basketball setTransform:CGAffineTransformMakeScale(2.0f, 2.0f)];
[UIView commitAnimations];
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜