ios下方滑出视图

-(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];
    }
}
posted @ 2012-07-04 16:11  xianyuan  阅读(311)  评论(0)    收藏  举报