• 记录一些容易忘记的属性 -- UINavigationController


      //设置导航栏的风格
        self.navigationController.navigationBar.barStyle = UIBarStyleDefault;
        //设置导航栏是否透明 NO不透明, YES 透明,默认为YES;

        //当导航栏的translucent属性设置为YES,则在当前视图控制器的坐标原点为屏幕左上角
        //当导航栏的translucent属性设置为NO,则在当前视图控制器的坐标原点在屏幕左上角(往Y轴方向距离导航栏的高度(44))
        self.navigationController.navigationBar.translucent =  NO;

        //设置导航栏上导航元素项的颜色
        self.navigationController.navigationBar.tintColor = [UIColor yellowColor];

        //设置导航栏的前景颜色
        self.navigationController.navigationBar.barTintColor = [UIColor cyanColor];

      //隐藏导航栏
        self.navigationController.navigationBarHidden = NO;
        
        //设置导航栏的背景图片
        //UIBarMetricsDefault 肖像画(正屏)
        //UIBarMetricsLandscapePhone 风景画(侧屏)
        [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"navBarBG1"] forBarMetrics:UIBarMetricsDefault];
        [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"navBarBG2"] forBarMetrics:UIBarMetricsLandscapePhone];

        //设置导航项的标题视图,这个优先级比下面的两种方式高
        UIView *titleView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 40, 40)];
        titleView.backgroundColor = [UIColor purpleColor];
        self.navigationItem.titleView = titleView;
        
        //设置视图控制器的名称
        //这两方式设置的优先级一致,谁后设置,用谁的名字
      1  self.navigationItem.title = @"controllOne";
      2  self.title = @"控制器一";

        //所有的导航元素项放在视图控制器的navigationItem里
        //所有的视图控制器都有自己独立的导航元素项,但是公用一个导航栏

        //裁剪超出边界的部分
        self.navigationController.navigationBar.clipsToBounds = YES;

  • 相关阅读:
    Codeforces Round #632 (Div. 2)
    Educational Codeforces Round 83 E. Array Shrinking
    Codeforces Round #626 D. Present
    I
    java学习-get和post请求
    java学习-MD5消息摘要算法
    分销系统数据库设计
    java获得当前日期是今年的第几周,以及这周的开始日期的方法
    分销系统的用户关系,用户与推广链接的数据库设计。设计思路
    git工具,conflict冲突解决方法
  • 原文地址:https://www.cnblogs.com/goodheart/p/3991417.html
Copyright © 2020-2023  润新知