状态栏(UITabBar)、导航栏(UINavigation)

视图控制器

一、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];
}

这里写图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值