IOS自定义导航栏Push动画效果
2015-03-26 13:23
375 查看
创建两个视图控制器,加到导航控制器上
#import "AppDelegate.h"
#import "FirstViewController.h"
@interface
AppDelegate ()
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary
*)launchOptions {
self.window = [[UIWindow
alloc] initWithFrame:[UIScreen
mainScreen].bounds];
self.window.backgroundColor = [UIColor
whiteColor];
[self.window
makeKeyAndVisible];
FirstViewController *firstCtrl = [[FirstViewController
alloc]
init];
UINavigationController *navCtrl = [[UINavigationController
alloc]
initWithRootViewController:firstCtrl];
self.window.rootViewController = navCtrl;
return
YES;
}
在FirstViewController中导入SecondViewController
#import "FirstViewController.h"
#import "SecondViewController.h"
@interface
FirstViewController ()
@end
@implementation FirstViewController
- (void)viewDidLoad {
[super
viewDidLoad];
self.title =
@"吃了吗";
self.view.backgroundColor = [UIColor
cyanColor];
UIButton *button = [UIButton
buttonWithType:UIButtonTypeRoundedRect];
button.frame =
CGRectMake(100,
100, 100,
100);
[button setTitle:@"push"
forState:UIControlStateNormal];
[button addTarget:self
action:@selector(buttonAction)
forControlEvents:UIControlEventTouchUpInside];
[self.view
addSubview:button];
}
//转场动画
- (void)transitionPush{
CATransition *tran = [CATransition
animation];
tran.duration =
.5;
tran.type =
@"pageCurl";
tran.subtype =
kCATransitionFromRight;
[self.navigationController.view.layer
addAnimation:tran
forKey:nil];
}
//按钮的点击时间,实现push动画效果
- (void)buttonAction{
[self
transitionPush];
SecondViewController *second = [[SecondViewController
alloc]
init];
[self.navigationController
pushViewController:second animated:YES];
}
SecondViewController.m中
#import "SecondViewController.h"
@interface
SecondViewController ()
@end
@implementation SecondViewController
- (void)viewDidLoad {
[super
viewDidLoad];
self.title =
@"吃的好饱啊";
self.view.backgroundColor = [UIColor
orangeColor];
}
#import "AppDelegate.h"
#import "FirstViewController.h"
@interface
AppDelegate ()
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary
*)launchOptions {
self.window = [[UIWindow
alloc] initWithFrame:[UIScreen
mainScreen].bounds];
self.window.backgroundColor = [UIColor
whiteColor];
[self.window
makeKeyAndVisible];
FirstViewController *firstCtrl = [[FirstViewController
alloc]
init];
UINavigationController *navCtrl = [[UINavigationController
alloc]
initWithRootViewController:firstCtrl];
self.window.rootViewController = navCtrl;
return
YES;
}
在FirstViewController中导入SecondViewController
#import "FirstViewController.h"
#import "SecondViewController.h"
@interface
FirstViewController ()
@end
@implementation FirstViewController
- (void)viewDidLoad {
[super
viewDidLoad];
self.title =
@"吃了吗";
self.view.backgroundColor = [UIColor
cyanColor];
UIButton *button = [UIButton
buttonWithType:UIButtonTypeRoundedRect];
button.frame =
CGRectMake(100,
100, 100,
100);
[button setTitle:@"push"
forState:UIControlStateNormal];
[button addTarget:self
action:@selector(buttonAction)
forControlEvents:UIControlEventTouchUpInside];
[self.view
addSubview:button];
}
//转场动画
- (void)transitionPush{
CATransition *tran = [CATransition
animation];
tran.duration =
.5;
tran.type =
@"pageCurl";
tran.subtype =
kCATransitionFromRight;
[self.navigationController.view.layer
addAnimation:tran
forKey:nil];
}
//按钮的点击时间,实现push动画效果
- (void)buttonAction{
[self
transitionPush];
SecondViewController *second = [[SecondViewController
alloc]
init];
[self.navigationController
pushViewController:second animated:YES];
}
SecondViewController.m中
#import "SecondViewController.h"
@interface
SecondViewController ()
@end
@implementation SecondViewController
- (void)viewDidLoad {
[super
viewDidLoad];
self.title =
@"吃的好饱啊";
self.view.backgroundColor = [UIColor
orangeColor];
}
相关文章推荐
- 【iOS学习笔记 15-11-06】简单自定义navigationcontroller push和pop动画效果
- 【iOS开发-24】导航控制器下不同视图控制器之间切换:利用CATrasition和view的layer层来实现自定义的动画效果
- iOS 自定义Tabbar实现push动画隐藏效果
- iOS 自定义转场动画实现小红书的push效果思路以及下雪碎屏等动画的实现
- iOS开发导航控制器下不同视图控制器之间切换:利用CATrasition和view的layer层来实现自定义的动画效果
- 源码推荐(8.17):闪屏效果,简易动画引擎,iOS UIView自定义四个边角的圆角
- iOS 7:自定义导航转场动画以及更多
- 自定义Tabbar实现push动画隐藏效果
- IOS开动画效果之──实现 pushViewController 默认动画效果
- iOS中用在导航控制器的转场动画(pop,push动画)制作
- iOS开发——UI进阶篇(十八)核心动画小例子,转盘(裁剪图片、自定义按钮、旋转)图片折叠、音量震动条、倒影、粒子效果
- ios 自定义弹出UIPickerView或UIDatePicker(动画效果)
- iOS学习之自定义弹出UIPickerView或UIDatePicker(动画效果)
- iOS 7:自定义导航转场动画以及更多
- iOS动画和特效(四)controller间的自定义过渡效果
- iOS 自定义push转场动画
- iOS_20_微博自定义可动画切换的导航控制器
- IOS开动画效果之──实现 pushViewController 默认动画效果
- Android UI设计之<二>自定义SwitchButton开关,实现类似IOS中UISwitch的动画效果
- iOS 7:自定义导航转场动画以及更多