-(void) slideIn { CGRect frame = self.slideView.frame; frame.origin = CGPointMake(0.0, self.view.bounds.size.height); self.slideView.frame = frame; [self.view addSubview:self.slideView]; [UIView beginAnimations:nil context:nil]; frame.origin = CGPointMake(0.0, self.view.bounds.size.height - self.slideView.bounds.size.height); self.slideView.frame = frame; [UIView commitAnimations]; } - (void) slideOut { [UIView beginAnimations:@"removeFromSuperviewWithAnimation" context:nil]; // Set delegate and selector to remove from superview when animation completes [UIView setAnimationDelegate:self]; [UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)]; // Move this view to bottom of superview CGRect frame = self.slideView.frame; frame.origin = CGPointMake(0.0, self.view.bounds.size.height); self.slideView.frame = frame; [UIView commitAnimations]; } // Method called when removeFromSuperviewWithAnimation's animation completes - (void)animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context { if ([animationID isEqualToString:@"removeFromSuperviewWithAnimation"]) { [slideView removeFromSuperview]; } }
转载于:https://www.cnblogs.com/loveyy/archive/2012/07/04/2576398.html