你好,歡迎來到IOS教程網

 Ios教程網 >> IOS編程開發 >> IOS開發綜合 >> ios開發:UINavigationController反方向滑動push

ios開發:UINavigationController反方向滑動push

編輯:IOS開發綜合

新建個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的動畫使用

  1. 上一頁:
  2. 下一頁:
蘋果刷機越獄教程| IOS教程問題解答| IOS技巧綜合| IOS7技巧| IOS8教程
Copyright © Ios教程網 All Rights Reserved