iOS]自动添加NavigationController自定义按钮动画 并且管理堆栈
来源:互联网 发布:淘宝网猎狐者户外用品 编辑:程序博客网 时间:2024/05/22 09:47
http://blog.cnbang.net/tech/1778/
问题
最初解决方法
最终解决方法
代码
01.
//.h
02.
#import <Foundation/Foundation.h>
03.
@interface MainNavigationController : UINavigationController {
04.
}
05.
@end
06.
07.
//.m
08.
#import "MainNavigationController.h"
09.
@implementation UIViewController (UINavigationButtonAnimate)
10.
- (
void
) viewAppearFromLeft
11.
{
12.
[self.navigationItem.leftBarButtonItem.customView setTransform:CGAffineTransformMakeTranslation(-60, 0)];
13.
[UIView beginAnimations:@
"viewAppearFromLeft"
context:nil];
14.
[UIView setAnimationDuration:0.3];
15.
[self.navigationItem.leftBarButtonItem.customView setAlpha:1.0];
16.
[self.navigationItem.leftBarButtonItem.customView setTransform:CGAffineTransformMakeTranslation(0, 0)];
17.
[UIView commitAnimations];
18.
}
19.
- (
void
) viewAppearFromRight
20.
{
21.
[self.navigationItem.leftBarButtonItem.customView setTransform:CGAffineTransformMakeTranslation(60, 0)];
22.
[UIView beginAnimations:@
"viewAppearFromRight"
context:nil];
23.
[UIView setAnimationDuration:0.3];
24.
[self.navigationItem.leftBarButtonItem.customView setAlpha:1.0];
25.
[self.navigationItem.leftBarButtonItem.customView setTransform:CGAffineTransformMakeTranslation(0, 0)];
26.
[UIView commitAnimations];
27.
}
28.
- (
void
) viewDisappearFromLeft
29.
{
30.
[UIView beginAnimations:@
"viewDisappearFromLeft"
context:nil];
31.
[self.navigationItem.leftBarButtonItem.customView setTransform:CGAffineTransformMakeTranslation(60, 0)];
32.
[UIView setAnimationDuration:0.3];
33.
[self.navigationItem.leftBarButtonItem.customView setAlpha:0];
34.
[UIView commitAnimations];
35.
}
36.
- (
void
) viewDisappearFromRight
37.
{
38.
[UIView beginAnimations:@
"viewDisappearFromRight"
context:nil];
39.
[self.navigationItem.leftBarButtonItem.customView setTransform:CGAffineTransformMakeTranslation(-60, 0)];
40.
[UIView setAnimationDuration:0.3];
41.
[self.navigationItem.leftBarButtonItem.customView setAlpha:0];
42.
[UIView commitAnimations];
43.
}
44.
@end
45.
46.
@implementation MainNavigationController
47.
- (UIViewController *)popViewControllerAnimated:(
BOOL
)animated
48.
{
49.
if
(animated) {
50.
UIViewController *popController = [self.viewControllers lastObject];
51.
UIViewController *pushController = [self.viewControllers objectAtIndex:self.viewControllers.count - 2];
52.
[popController viewDisappearFromLeft];
53.
[pushController viewAppearFromLeft];
54.
}
55.
return
[super popViewControllerAnimated:animated];
56.
}
57.
- (
void
)pushViewController:(UIViewController *)viewController animated:(
BOOL
)animated
58.
{
59.
if
(animated) {
60.
UIViewController *popController = [self.viewControllers lastObject];
61.
UIViewController *pushController = viewController;
62.
[popController viewDisappearFromRight];
63.
[pushController viewAppearFromRight];
64.
}
65.
[super pushViewController:viewController animated:animated];
66.
}
67.
@end
0 0
- iOS]自动添加NavigationController自定义按钮动画 并且管理堆栈
- NavigationController自定义返回按钮
- 自定义navigationcontroller返回动画
- IOS 自定义tabBar的按钮添加点击放大缩小的动画
- iOS 在NavigationController 基类中 自定义全局后退按钮 且 开启手势后退
- 【iOS学习笔记 15-11-06】简单自定义navigationcontroller push和pop动画效果
- NavigationController 自定义pop和push动画
- IOS:修改NavigationController的后退按钮标题
- ios NavigationController里面默认得返回按钮
- IOS:修改NavigationController的后退按钮标题
- IOS:修改NavigationController的后退按钮标题
- ios navigationcontroller 返回按钮标题动态更改
- ios navigationController导航跳转方式自定义
- iOS中自定义导航控制器NavigationController
- navigationController push的view不添加返回按钮
- 自定义 NavigationController
- 自定义navigationController的左侧按钮后返回手势失灵解决办法
- 自定义NavigationController 的Push 和 Pop过渡动画
- C++下Windows Forms + MFC + WTL + wxWidgets + Qt + GTK+ 非官方综合比较
- Android应用如何监听自己是否被卸载及卸载反馈功能的实现
- WPF、Windows Forms和Silverlight间的联系和区别
- MongoDB集群
- HDU 2586 How far away ?(LCA)
- iOS]自动添加NavigationController自定义按钮动画 并且管理堆栈
- LA3942 Remember the Word(Trie+DP)
- c++操作笔记阅读笔记
- mysql 按年度、季度、月度、周、日SQL统计查询
- MongoDB集群——副本集
- mysql时间格式化
- hive bucket
- Inside CAB Dependency Injection
- 剪贴板