简体   繁体   中英

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 (basketball.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];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM