UINavigationController(导航控制器)
2015-12-27 14:07
621 查看
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]; }
相关文章推荐
- Implement Stack using Queues 用队列实现栈
- CUICatalog: Invalid asset name supplied: (null)
- C#_Dictionary<TKey, TValue>的使用
- 允许 UIAccess 应用程序在提升时进行提示,而无需使用安全桌面
- UIView
- 为OLED屏增加GUI支持2:2D图形库
- UISwitch
- UIButton
- 使用EasyUI实现加入和删除功能
- android127 zhihuibeijing 屏幕适配
- UIKit - UIImage 详解
- Win10系统下软件UI显示不完整解决方案
- CALayer与UIView及一些基本的3D变换
- Arduino - 中断的使用
- miniui datagrid 保存到服务端,使用.NET 自带 JSON 转换时发现日期格式不兼容。
- C#操作xml文档,cuid,dategridview显示数据
- C#操作xml文档,cuid,dategridview显示数据
- Winform实现多线程异步更新UI(进度及状态信息)
- UIGestureRecognizer,手势处理,点击,长按,拖动,左右划动
- 如何避免GUIDE自动代码的Warning