UINavigationController(导航控制器)
来源:互联网 发布:qt初学者 知乎 编辑:程序博客网 时间:2024/05/23 13:08
UINavigationController(导航控制器)
界面可以滑动,多用于做轮播图
//修改导航视图控制器的半透明效果,默认是YES self.navigationController.navigationBar.translucent=NO; //修改背景颜色 self.navigationController.navigationBar.barTintColor=[UIColor orangeColor]; self.title=@"第一页";
//(1)标题// self.navigationItem.title=@"豆瓣电影";// self.title=@"天猫首页"; //两个都可以 注:self.title后面的标题也会跟着改变// UISegmentedControl *seg=[[UISegmentedControl alloc] initWithItems:@[@"信息",@"通话"]];// self.navigationItem.titleView=seg;// [seg release]; //可以把label放到titleView上,能修改label的内容,比如字体的大小// UILabel *label=[[UILabel alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];// label.text=@"豆瓣电影";// self.navigationItem.titleView=label;// [label release];// label.font=[UIFont systemFontOfSize:25];
创建按钮
//创建左边的按钮 self.navigationItem.leftBarButtonItem=[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemPlay target:self action:@selector(barAction:)]; //第二种方式self.navigationItem.rightBarButtonItem=[[[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"1.jpg"] style:UIBarButtonItemStylePlain target:self action:@selector(barAction:)] autorelease]; //第三种方式 self.navigationItem.rightBarButtonItem=[[UIBarButtonItem alloc] initWithTitle:@"确认" style:UIBarButtonItemStylePlain target:self action:@selector(barAction:)]; //第四种,使用自定义的视图 UIButton *button=[UIButton buttonWithType:UIButtonTypeCustom]; [button setImage:[UIImage imageNamed:@"1.jpg"] forState:UIControlStateNormal]; button.frame=CGRectMake(0, 0, 40, 40); self.navigationItem.rightBarButtonItem=[[UIBarButtonItem alloc] initWithCustomView:button];
跳转页面
//跳转按钮UIButton *pushButton=[UIButton buttonWithType:UIButtonTypeSystem]; pushButton.frame=CGRectMake(100, 100, 150, 50); pushButton.layer.borderWidth=1; pushButton.layer.cornerRadius=10; [pushButton addTarget:self action:@selector(click:) forControlEvents:UIControlEventTouchUpInside]; [pushButton setTitle:@"下一页" forState:UIControlStateNormal]; [self.view addSubview:pushButton];
点击方法-(void)click:(UIButton *)button{ //模态跳转(复习)// SecondViewController *secVC=[[SecondViewController alloc] init];// [secVC setModalTransitionStyle:0];// [self presentViewController:secVC animated:YES completion:^{// // }];//通过导航视图控制器进行跳转操作 //1.创建下一页的目标对象 SecondViewController *secVC=[[SecondViewController alloc] init]; //2.跳转 [self.navigationController pushViewController:secVC animated:YES]; //3.内存管理 [secVC release];}
从第二页跳转回来的点击方法
-(void)click:(UIButton *)button{ ThirdViewController *thirdVC=[[ThirdViewController alloc] init]; [self.navigationController pushViewController:thirdVC animated:YES]; [thirdVC release];}
0 0
- 导航视图控制器UINavigationController
- 导航控制器 ( UINavigationController )
- 导航控制器UINavigationController
- UINavigationController导航控制器详解
- UINavigationController导航控制器…
- UINavigationController导航控制器…
- UINavigationController导航控制器…
- UINavigationController 导航控制器
- 导航控制器UINavigationController
- 导航控制器:UINavigationController
- 自定义UINavigationController(导航控制器)
- swift UINavigationController 导航控制器
- UINavigationController 导航视图控制器
- UINavigationController 导航控制器
- UINavigationController 导航控制器
- UINavigationController导航控制器
- UI UINavigationController导航控制器
- UINavigationController---导航控制器
- 关于 UIApplication sharedApplication 简单使用
- 从零开始写javaweb框架笔记9-细节完善与代码优化-完善控制器层
- ARM-LINUX开发环境的搭建(一)
- 为什么要“用户协议”?
- C语言学习笔记-------伊能C语言学习笔记------静态函数初步
- UINavigationController(导航控制器)
- Hadoop笔记(二)
- 设计模式六大原则(3):依赖倒置原则
- java中的静态块
- MySQL外键设置中的的 Cascade、NO ACTION、Restrict、SET NULL
- c#中调用DLL
- 静态语言和动态语言
- [LeetCode-230]Kth Smallest Element in a BST
- 常用java编译器总结