Skip to content

Instantly share code, notes, and snippets.

@zzz6519003
Created July 18, 2014 07:18
Show Gist options
  • Save zzz6519003/078cceccdc2ffd76e482 to your computer and use it in GitHub Desktop.
Save zzz6519003/078cceccdc2ffd76e482 to your computer and use it in GitHub Desktop.
rtPushViewController
- (void)rtPushViewController:(UIViewController *)viewController animated:(BOOL)animated{
if ([self respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithTitle:@"返回" style:UIBarButtonItemStyleBordered target:self action:nil];
self.topViewController.navigationItem.backBarButtonItem = backItem;
[backItem release];
} else {
UIImage *image = [UIImage iconForNavBack];
UIImage *highlighted = [UIImage iconForNavBackSelected];
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
button.frame = CGRectMake(0, 0, image.size.width, 44);
[button setImage:image forState:UIControlStateNormal];
[button setImage:highlighted forState:UIControlStateHighlighted];
[button addTarget:self action:@selector(customBackClick) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithCustomView:button];
viewController.navigationItem.leftBarButtonItem = backItem;
[backItem release];
}
[self pushViewController:viewController animated:animated];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment