影响 View 布局区域的有以下三个属性:
self.edgesForExtendedLayout (影响View布局区域的主要属性)
self.navigationController.navigationBar.translucent (navigationBar 是否半透明)
self.tabBarController.tabBar.translucent (tabBar 是否半透明)
 
-------------------------------------------------------------------------------------
case 1: edgesForExtendedLayout = UIRectEdgeAll
条件: navigationBar.translucent = YES && tabBar.translucent = YES
结果: View Top == navigationBar Top,View Bottom == tabBar Bottom
 
条件: navigationBar.translucent = NO && tabBar.translucent = YES
结果: View Top == navigationBar Bottom,View Bottom == tabBar Bottom
 
条件: navigationBar.translucent = YES && tabBar.translucent = NO
结果: View Top == navigationBar Top,View Bottom == tabBar Top
 
条件: navigationBar.translucent = NO && tabBar.translucent = NO
结果: View Top == navigationBar Bottom,View Bottom == tabBar Top
-------------------------------------------------------------------------------------
case 2: edgesForExtendedLayout = UIRectEdgeTop
条件: navigationBar.translucent = YES && tabBar.translucent = YES
结果: View Top == navigationBar Top,View Bottom == tabBar Top
 
条件: navigationBar.translucent = NO && tabBar.translucent = YES
结果: View Top == navigationBar Bottom,View Bottom == tabBar Top
 
条件: navigationBar.translucent = YES && tabBar.translucent = NO
结果: View Top == navigationBar Top,View Bottom == tabBar Top
 
条件: navigationBar.translucent = NO && tabBar.translucent = NO
结果: View Top == navigationBar Bottom,View Bottom == tabBar Top
-------------------------------------------------------------------------------------
case 3: edgesForExtendedLayout = UIRectEdgeBottom
条件: navigationBar.translucent = YES && tabBar.translucent = YES
结果: View Top == navigationBar Bottom,View Bottom == tabBar Bottom
 
条件: navigationBar.translucent = NO && tabBar.translucent = YES
结果: View Top == navigationBar Bottom,View Bottom == tabBar Bottom
 
条件: navigationBar.translucent = YES && tabBar.translucent = NO
结果: View Top == navigationBar Bottom,View Bottom == tabBar Top
 
条件: navigationBar.translucent = NO && tabBar.translucent = NO
结果: View Top == navigationBar Bottom,View Bottom == tabBar Top
-------------------------------------------------------------------------------------
case 4: edgesForExtendedLayout = UIRectEdgeNone
条件: navigationBar.translucent = YES && tabBar.translucent = YES
结果: View Top == navigationBar Bottom,View Bottom == tabBar Top
 
条件: navigationBar.translucent = NO && tabBar.translucent = YES
结果: View Top == navigationBar Bottom,View Bottom == tabBar Top
 
条件: navigationBar.translucent = YES && tabBar.translucent = NO
结果: View Top == navigationBar Bottom,View Bottom == tabBar Top
 
条件: navigationBar.translucent = NO && tabBar.translucent = NO
结果: View Top == navigationBar Bottom,View Bottom == tabBar Top
-------------------------------------------------------------------------------------
 
iOS 7.0以后
self.navigationController.navigationBar.translucent 和 self.tabBarController.tabBar.translucent 默认值都为 YES.
iOS 6.0以下系统
navigationBar 和 tabBar 默认都是不透明的。
 
edgesForExtendedLayout 的枚举项:
UIRectEdgeNone = 0, navBar 底部与 tabBar 上部之间
UIRectEdgeTop = 1 << 0, navBar 上部与 tabBar 上部之间
UIRectEdgeLeft = 1 << 1,
UIRectEdgeBottom = 1 << 2, navBar 底部与 tabBar 底部之间
UIRectEdgeRight = 1 << 3,
UIRectEdgeAll = UIRectEdgeTop | UIRectEdgeLeft | UIRectEdgeBottom | UIRectEdgeRight
 
下面图中展示了 UIView 的四种情况下的布局区域,绿色为目标 UIView:
View Top == navigationBar Bottom,View Bottom == tabBar Top
 

View Top == navigationBar Top,View Bottom == tabBar Bottom

 
View Top == navigationBar Bottom,View Bottom == tabBar Bottom

 
View Top == navigationBar Top,View Bottom == tabBar Top

 
注:
本文是受 http://blog.sina.com.cn/s/blog_1410870560102wu9a.html 启发而写的一篇文章。
本文论证结果是在xcode iOS 12.1 IPhone XR 模拟器上进行的数据校对。

总结UIViewController的view在有navBar和tabBar影响下布局区域的问题的更多相关文章

  1. UIViewController的View显示在导航栏下面如何解决?

    ios7之前的版本中UIViewController中的view在显示后会自动调整为去掉导航栏的高度的,控件会自动在导航栏以下摆放. 在iOS7中UIViewController的wantsFullS ...

  2. iOS-实现映客首页TabBar和滑动隐藏NavBar和TabBar

    之前在做直播的时候,参照了映客App,发现其首页的效果还挺不错,在网上找了一下相关仿映客App代码和博客,大部分都是说如何播放直播流和推流,对于UI这块甚少,所以我自己花了点时间研究了一下映客的首页U ...

  3. Navbar和Tabbar常用设置

    1.navBar [self.navigationController.navigationBar setBackgroundImage:navBarImage forBarMetrics:UIBar ...

  4. Android学习笔记_31_通过后台代码生成View对象以及动态加载XML布局文件到LinearLayout

    一.布局文件part.xml: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android&qu ...

  5. Change Field Layout and Visibility in a List View 在列表视图中更改字段布局和可见性

    This lesson will guide you through the steps needed to select columns displayed in the List View. Fo ...

  6. 'NSInternalInconsistencyException', reason: '-[UIViewController _loadViewFromNibNamed:bundle:] loaded the "XXXView" nib but the view outlet was not set.' 崩溃问题

    先说下我遇到这个崩溃问题的原因: 自定义的Viewxib和系统的 View重名,导致崩溃 我的理解是我这里加载YJLoginViewController 的时候,YJLoginViewControll ...

  7. 怎么让self.view的Y从navigationBar下面开始计算

    原文地址 http://blog.sina.com.cn/s/blog_1410870560102wu9a.html 在iOS 7中,苹果引入了一个新的属性,叫做[UIViewController s ...

  8. UIViewController生命周期-完整版

    一.UIViewController 的生命周期 下面带 (NSObject)的方法是NSObject提供的方法.其他的都是UIViewController 提供的方法. load   (NSObje ...

  9. 8. UIViewController

    1. UIViewController 的认识 UIViewController在iOS开发中占据很重要的位置,iOS的整个UI开发的核心思想也是MVC的架构,从UIViewController的命名 ...

随机推荐

  1. Manual write code to record error log in .net by Global.asax

    完整的Glabal.asax代码: <%@ Application Language="C#" %> <script RunAt="server&quo ...

  2. Java 学习(1)----- java 学习的总体感觉

    好久没有更新博客了,是因为最近在集中精力学习java, Java 的基础知识确实是比 js 多太多了. 学习java 断断续续的差不多有一年左右的时间, 这一年来,感觉懂了一点,过一段时间又忘记了,总 ...

  3. react native定报预披项目知识点总结

    1.TextInput组件对安卓的适配问题 textInput 在iOS 显示正常,但是在android下会出现下横线,并且字会被遮盖 因此一般都这么用该组件 <TextInput style= ...

  4. 在php中实现Redis的订阅与发布

    <?php //require_once dirname(__FILE__).'/class/RedisClass.class.php'; function init_redis(){ $red ...

  5. java容器-Map

    Map:基本思想是映射表(维护键-值对),HashMap,TreeMap,LinkedHashMap,ConcurrentHashMap等都是基于Map接口实现的map容器,他们特性不同,表现在效率, ...

  6. 【小白学Lua】之Lua变长参数和unpack函数

    一.简介 Lua的变长参数和unpack函数在实际的开发中应用的还挺多的,比如在设计print函数的时候,需要支持对多个变量进行打印输出,这时我们就需要用到Lua中的变长参数和unpack函数了. 二 ...

  7. AFM论文精读

    深度学习在推荐系统的应用(二)中AFM的简单回顾 AFM模型(Attentional Factorization Machine) 模型原始论文 Attentional Factorization M ...

  8. JavaScript数据类型 Math对象详解

    前言 javascript使用算术运算符实现基本的算术运算,如果要实现更加复杂的算术运算,需要通过Math对象定义的常量和函数来实现.和其他对象不同,Math只是一个静态对象,并没有Math()构造函 ...

  9. [Reinforcement Learning] Model-Free Prediction

    上篇文章介绍了 Model-based 的通用方法--动态规划,本文内容介绍 Model-Free 情况下 Prediction 问题,即 "Estimate the value funct ...

  10. 五十八、linux 编程——UDP 编程 广播

    58.1 广播介绍 58.1.1 介绍 广播实现一对多的通讯 它通过向广播地址发送数据报文实现的 58.1.2 套接字选项 套接字选项用于修饰套接字以及其底层通讯协议的各种行为.函数 setsocko ...