状态栏(UITabBar)、导航栏(UINavigation)
来源:互联网 发布:数据山东吧 编辑:程序博客网 时间:2024/05/17 09:28
视图控制器
一、UITabBarController 工具栏控制器(选项卡控制器)
UITabBar 选项卡栏
尺寸:320*49px
属性:
图标或文字颜色
tbBar.tabBar.tintColor = [UIColor yellowColor];
背景颜色
tbBar.tabBar.barTintColor = [UIColor blackColor];
背景图片
tbBar.tabBar.backgroundImage = [UIImage imageNamed:@”tab_49”];
UITabBarItem 选项卡项
Badge 右上角标识
关系
1.创建基本的视图控制器
OneViewController *one = [[OneViewController alloc] init];
TwoViewController *two = [[TwoViewController alloc] init];
2.创建导航栏控制器
UINavigationController *nav1 = [[UINavigationController alloc] initWithRootViewController:one];
UINavigationController *nav2 = [[UINavigationController alloc] initWithRootViewController:two];
3.创建选项卡控制器
UITabBarController *tabBar = [[UITabBarController alloc] init];
tabBar.viewControllers = @[nav1,nav2];
设置选项卡项的内容
nav1.tabBarItem.title = @”美女1”;
nav1.tabBarItem.image = [UIImage imageNamed:@”tabbar_1”];
nav2.tabBarItem.title = @”美女2”;
nav2.tabBarItem.image = [UIImage imageNamed:@”tabbar_2”];
设置导航栏项的内容
one.navigationItem.title = @”美女1”;//标题
two.navigationItem.title = @”美女2”;//标题
二、UINavigationController 导航栏控制器
UINavigationBar 导航栏
尺寸:
7.0之前 44px
7.0以后 44+20(状态栏)px
属性:
背景颜色
self.navigationController.navigationBar.barTintColor = [UIColor redColor];
按钮颜色
self.navigationController.navigationBar.tintColor = [UIColor greenColor];
背景图片
[self.navigationController.navigationBar setBackgroundImage:img forBarMetrics:UIBarMetricsDefault];
标题样式(颜色、字体)
self.navigationController.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName:[UIColor whiteColor],NSFontAttributeName:[UIFont systemFontOfSize:14.0]};
是否透明
self.navigationController.navigationBar.translucent = flag;
创建导航栏按钮的三种方式:
1.创建自带标题的按钮
UIBarButtonItem *item1 = [[UIBarButtonItem alloc] initWithTitle:@”添加” style:UIBarButtonItemStyleDone target:nil action:nil];
2.创建系统自带的按钮
UIBarButtonItem *item2 = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:nil action:nil];
3.创建自带图片的按钮
UIBarButtonItem *item3 = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@”cc”] style:UIBarButtonItemStyleDone target:nil action:nil];
导航栏跳转
push 导入(入栈)
ThreeViewController *two = [[ThreeViewController alloc] init];
[self.navigationController pushViewController:two animated:YES];
pop 导出(出栈)
返回上一级
[self.navigationController popViewControllerAnimated:YES];
返回顶层
[self.navigationController popToRootViewControllerAnimated:YES];
返回指定层
[self.navigationController popToViewController:[self.navigationController.viewControllers objectAtIndex:0] animated:YES];
隐藏返回按钮
self.navigationItem.hidesBackButton = YES;
设置是否隐藏导航栏
[self.navigationController setNavigationBarHidden:YES animated:YES];
加载半透明背景
[[UIApplication sharedApplication].keyWindow.rootViewController.view addSubview:_popView];
- (void)bgImageView_method { // 半透明背景 _bgImage= [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, XBScreenWidth, XBScreenHeight)]; [[UIApplication sharedApplication].keyWindow.rootViewController.view addSubview:_bgImage]; _bgImage.backgroundColor = [UIColor blackColor]; _bgImage.alpha = 0.5; _popView = [[UIView alloc]init]; [[UIApplication sharedApplication].keyWindow.rootViewController.view addSubview:_popView]; [_popView zxp_addConstraints:^(ZXPAutoLayoutMaker *layout) { layout.centerByView(_bgImage,0); layout.leftSpace(10); layout.rightSpace(10); layout.heightValue(168); }]; _popView.backgroundColor = [UIColor whiteColor]; UIButton *backbtn = [[UIButton alloc] init]; [_popView addSubview:backbtn]; [backbtn zxp_addConstraints:^(ZXPAutoLayoutMaker *layout) { layout.topSpace(7); layout.rightSpace(8); layout.widthValue(21); layout.heightValue(21); }]; [backbtn addTarget:self action:@selector(dismissView) forControlEvents:UIControlEventTouchUpInside]; [backbtn setBackgroundImage:[UIImage imageNamed:@"close_cheat_page"] forState: UIControlStateNormal];}
- 状态栏(UITabBar)、导航栏(UINavigation)
- UITabBar和UINavigation碰到的几个问题 (系统颜色)
- UITabBar&UINavigation
- IOS导航栏UINavigation
- UINavigation导航栏颜色
- 导航状态栏(UINavigationBar)和分栏状态栏(UITabBar)
- IOS Swift3.0自定义导航栏(UINavigation)
- UINavigation 导航控制器
- ios中UINavigation和UITabBar的结合
- ios中UINavigation和UITabBar的结合
- iOS开发UINavigation——导航栏UINavigtionBar
- UINavigation导航栏和UITableviewcell点击事件写法
- (转)定制iOS 7中的导航栏和状态栏
- ios导航栏,状态栏自定义设计相关参数 (转)
- 定制iOS 7中的导航栏和状态栏(转)
- iOS开发--代码块 (得到状态栏,导航栏高度)
- Android 4.4之后状态栏和导航栏细节美化(沉浸式状态栏)
- 导航栏、状态栏设置
- 100道ios面试题目的总结体会
- 深入理解seajs之入门
- udev用法
- 20个命令行工具监控 Linux 系统性能
- 解除svn版本控制
- 状态栏(UITabBar)、导航栏(UINavigation)
- java继承小实例
- 系统定义弹窗以及自定义弹窗
- Websocket(3)--实时推送
- vector push_back报错 是其他地方内存越界覆盖掉了后面的内存
- No JNI_OnLoad found in ......, skipping init
- js实现百度动态LOGO
- PAT--1085 Perfect Sequence(二分查找)
- ios开发动画效果的基本学习介绍