简体   繁体   中英

hiding a UIView while moving it in animation

I have some animation that does some rotation using beginAnimations. I want to hide the UIview in question, of course I tried changing the hidden property but nothing happened. Here is the code

 CGAffineTransform rotation = CGAffineTransformMakeRotation( angelToRotate(-90));
[UIView beginAnimations: @"" context: NULL];
self.view.hidden = TRUE;
[UIView setAnimationDuration: 0.4];
self.view.transform = CGAffineTransformConcat(self.view.transform, rotation);
self.view.hidden = FALSE;
[UIView commitAnimations];

I also tried changing the alpha on the view, but still nothing.

Any ideas?

CGAffineTransform rotation = CGAffineTransformMakeRotation( angelToRotate(-90));   
[UIView animateWithDuration:0.4 animations:^
{
    self.view.transform = CGAffineTransformConcat(self.view.transform, rotation);
    self.view.alpha = 0.0;
}
completion:^(BOOL finished)
{
    self.view.alpha = 1.0;
}];

Or:


CGAffineTransform rotation = CGAffineTransformMakeRotation( angelToRotate(-90));
[UIView beginAnimations:nil context: NULL];
[UIView setAnimationDuration:0.4];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];
self.view.transform = CGAffineTransformConcat(self.view.transform, rotation);
self.view.alpha = 0.0;
[UIView commitAnimations];

- (void) animationDidStop: (NSString *) animationID finished: (NSNumber *) finished context: (void *) context
{
    self.view.alpha = 1.0;
}

as a start try taking away the self.view.hidden = TRUE IF I get your code correctly, animation should disappear and reappear after .4 seconds?

Hiding and Showing on the same function doesn't work that way.

You could call another function that specifically does self.view.hidden = FALSE

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