ios开发:UINavigationController反方向滑动push

新建个UINavigationController的类别:


#import "UINavigationController+CustomAnimation.h"


@implementation UINavigationController (CustomAnimation)


- (void)customPushViewController:(UIViewController *)viewController

{

    viewController.view.frame = (CGRect){-viewController.view.frame.size.width, 0, viewController.view.frame.size};

    [self.topViewController.view addSubview:viewController.view];

    [UIView animateWithDuration:.35f

                     animations:^{

                         viewController.view.frame = (CGRect){0, 0, self.view.bounds.size};

                     }];

}

@end


这种方法是将新的View 加到了self.navigationController.topViewController 上,然后加上了滑动动画。

使用

- (void)backToHome

{

    [UIView beginAnimations:@"popView" context:NULL];

    [UIView setAnimationDelegate:self];

    [UIView setAnimationDuration:.5f];

    [UIView setAnimationDidStopSelector:@selector(popAnimationDidStop)];

    self.view.frame = CGRectMake(-CGRectGetWidth(self.view.frame), 0, CGRectGetWidth(self.view.frame), CGRectGetHeight(self.view.frame));

    [UIView commitAnimations];

}

可以作为pop的动画使用

ios开发:UINavigationController反方向滑动push,布布扣,bubuko.com

ios开发:UINavigationController反方向滑动push

上一篇:Android异步HTTP客户端的特点


下一篇:android利用videoView播放视频(已封装)