I just noticed the iOS 6/7 Delta property found under the UIView's structs layout.

What is this for and why is this missing from AutoLayout?

asked Jul 22 at 17:46
 
7  
I believe this is available only in Xcode5 which is under NDA. So please post your question to devforums.apple.com. –  rajagp Jul
22 at 21:17

4 Answers

up
vote
49down
vote
accepted

This actually refers to the Delta between layout position from iOS6 to iOS7.

In iOS7, some views can hide the status bar or have it transparent and, in effect, it is overlaid on top of your view. So if you put a UI element at (0.0, 0.0) on iOS6, it will appear below the status bar, but on iOS7 it would appear partially covered underneath
the status bar. So in that case you would want a delta that matches the status bar height (20.0 points) so that the layout looks the same in iOS6 and iOS7.

I believe this isn't needed if you use autolayout, but of course, then you lose iPad1 support, which many of us aren't willing to concede at this point in time.

answered Sep 11 at 15:11
digarok

51867
 
12  
For me, I found it is the delta from iOS 7 to iOS 6. I lowered my elements 20 points, then set a -20 for Delta Y. –  sguptaet Sep
17 at 3:08
 
this is particularly useful with the UIProgressView which is much slimmer in iOS 7 –  Lee
Probert
 Sep
27 at 14:19

Note: I noticed this question a while ago, but I'm only posting my answer now because the NDA has been lifted

Why does it not appear for AutoLayout?

As you may have noticed, iOS 7 brings about a whole new look. The look of UI elements have changed, but also so have some of their sizes (or metrics in general). This can make interface design to accommodate both iOS 7 and it's predecessors a bit of a pain.

Apple's official line is to use AutoLayout to solve this; this should take a lot of the hassle out of laying out UI elements for you. Sometimes incorporating this is not easily done, especially if you must still support iOS 5 for business reasons, or your interfaces
are managed in a way that makes implementing AutoLayout difficult. As such, Apple seems to have provided a way to make your job a bit easier if you fall into this niche category, and they've called this iOS 6/7 Deltas.

Ok then, what does it do?

Whilst the label in Interface Builder is a bit unclear as to what 'Delta' means in this context, the code contained in the .xib file that corresponds to this feature is a bit more clear:

<inset key="insetFor6xAndEarlier"
minX="-50" minY="-100" maxX="-50" maxY="300"/>

The key name insetFor6xAndEarlier explicitly
states what this does; you can provide alternative insets for UI elements when run on iOS 7's predecessors. For example, the above defines the following delta change:

x: 50
y: 100
width: -100
height: 200

Whilst the values stored in the .xib doesn't correspond to the quoted values directly, there is a correlation between them.

x: -minX
y: -minY
width: minX + maxX
height: minY + maxY

The images below shows this change visually. It's quite an extreme example, but it's to demonstrate its ability. I would only expect in practice to have delta changes of only a few pixels.

You may notice that the values are the inverse for the iOS 6 view; this is because the deltas are relative to the type of view you're working with. If you're editing for iOS 6, the deltas there are in order to transform the element correctly for iOS 7 (the
reverse of the example above).

In order to view the different styles, you can change the way Interface Builder presents it based on the OS it would be running on. This is contained within the File Inspector->Interface Builder Document (1st tab on the right bar), as so:

Does this exist if I like to code my interface by hand?

Not directly, but you can easily achieve the same effect by having conditional checks on OS version within your code, and setting the correct position/size accordingly. The delta ability exists in Interface Builder because there would be no straightforward
way to have conditional positioning without having code to do it, and the point of Interface Builder is to get a much code out of the way as possible for UI.

Overall...

Apple strongly recommend that you use AutoLayout, it makes your life easier in most cases. If you can't use it (for reasons mentioned above), deltas provide you with the flexibility to position your UI elements appropriately, based on the current OS's metrics,
without the need to manually reposition them in code. A good example is to adjust for the lack of status bar, but there are plenty of other use cases.

Naturally, if you're only developing for iOS7 and above, you don't need to know this feature/won't discover it. Only if you need to have iOS6 devices running your application when built with the iOS7 SDK, without autolayout, do you need deltas.

At the time of writing (21st August), I can't find any documentation regarding this feature, nor any mentions in the WWDC material. I've had a play around, and after a bit of research, that is what I've discovered.

answered Sep 18 at 11:16
WDUK

7,919928
 
 
Thank you very much WDUK –  Kamarshad Sep
25 at 11:00
 
 
Superb answer +1 –  Brad
Thomas
 Oct
4 at 13:07
 
Awesome answer, thanks! –  Tuszy Oct
25 at 11:47

I know this is already been answered, just adding a small variant hoping it could also help those who don't use auto layout and still want to support iOS 6.1 and earlier versions.

Read this Apple's
Transition Guide - Supporting earlier version

Choose 'View as' to 'iOS 7.0 and Later'

Base UI for iOS 7. For iOS 6 give suitable delta value. Use preview to see how this will render in iOS 7 and iOS 6 device.

Quick steps:

Select each immediate children of root view individually and add 20px to its 'Y' value.

Then, select all immediate children collectively and give delta Y as -20px. You can also do this in batch or individually.

answered Sep 24 at 10:28
Galaxy

848213
 
1  
most useful answer yet..thanks :) –  codeburn Oct
1 at 12:49

AutoLayout requires at least iOS 6.0. If you want to support iOS 5.0 you couldn't use AutoLayout.

And those deltas are used to help you adjust the view position on different iOS version(mainly iOS 7 and iOS version lower than 7).

I use those value to help me like this picture. 


Interface Builder: What are the UIView's Layout iOS 6/7 Deltas for?的更多相关文章

  1. iOS 8 Auto Layout界面自动布局系列2-使用Xcode的Interface Builder添加布局约束

    http://blog.csdn.net/pucker/article/details/41843511 上一篇文章<iOS 8界面自动布局系列-1>简要介绍了iOS界面布局方式的前世今生 ...

  2. 【转 iOS 8 Auto Layout界面自动布局系列2-使用Xcode的Interface Builder添加布局约束

    原文网址:http://blog.csdn.net/pucker/article/details/41843511 上一篇文章<iOS 8界面自动布局系列-1>简要介绍了iOS界面布局方式 ...

  3. iOS杂谈-我为什么不用Interface builder

    在互联网上关于Interface Builder的争吵每天都在发生,用和不用大家都有一大堆的理由.最近看了这篇文章,很多地方和作者有共鸣,结合自己的一些经历,就有了你现在所看到的东西,你可以把它当成前 ...

  4. 浅析 - 提高xib(Interface Builder)高效工作的几个小技巧

    本文译自:8 Tips for working effectively with Interface Builder(需FQ)先来看看目录:介绍使view的Size与view中的Content相适应按 ...

  5. iOS开发工具Xcode:Interface Builder

    简介: Interface Builder(IB)是Mac OS X平台下用于设计和测试用户界面(GUI)的应用程序(非开源).为了生成GUI,IB并不是必需的,实际上Mac OS X下所有的用户界面 ...

  6. 【Xamarin挖墙脚系列:代码手写UI,xib和StoryBoard间的博弈,以及Interface Builder的一些小技巧(转)】

    正愁如何选择构建项目中的视图呢,现在官方推荐画板 Storybord...但是好像 xib貌似更胜一筹.以前的老棒子总喜欢装吊,用代码写....用代码堆一个HTML页面不知道你们尝试过没有.等页面做出 ...

  7. MacRuby 0.3发布,支持Interface Builder,和创建GUI用的HotCocoa

    作者 Werner Schuster ,译者 贾晓楠 发布于 2008年9月24日 | 分享到: 微博 微信 QQ空间 LinkedIn Facebook 邮件分享 稍后阅读 我的阅读清单 现在,Ma ...

  8. 代码手写UI,xib和StoryBoard间的博弈,以及Interface Builder的一些小技巧

    近期接触了几个刚入门的iOS学习者,他们之中存在一个普遍和困惑和疑问.就是应该怎样制作UI界面.iOS应用是非常重视用户体验的,能够说绝大多数的应用成功与否与交互设计以及UI是否美丽易用有着非常大的关 ...

  9. 提高Interface Builder高效工作的8个技巧

    本文转载至 http://www.cocoachina.com/ios/20141106/10151.html iOS开发Interface Builder 本文译自:8 Tips for worki ...

随机推荐

  1. Java-Maven-pom.xml-project-dependencies:dependencies

    ylbtech-Java-Maven-pom.xml-project-dependencies:dependencies 1.java 调用ddl <!-- java 调用ddl --> ...

  2. http://www.narkii.com/club/forum-46-1.html 纳金学习论坛,主要是讨论一些unty3D方面的事情,技术栈比较前沿,

    http://www.narkii.com/club/forum-46-1.html  纳金学习论坛,主要是讨论一些unty3D方面的事情,技术栈比较前沿,

  3. 深入分析Service启动、绑定过程

    Service是Android中一个重要的组件,它没有用户界面,可以运行在后太做一些耗时操作.Service可以被其他组件启动,甚至当用户切换到其他应用时,它仍然可以在后台保存运行.Service 是 ...

  4. 压测:mysqlslap

    MySQL从5.1.4版开始带有一个压力测试工具mysqlslap,通过模拟多个并发客户端访问mysql来执行测试,使用起来非常简单,通过mysqlslap –help可以获得可用的选项.这里列一些主 ...

  5. 实现ViewPager的联动效果

    参考链接:android - Synchronizing two ViewPagers using OnPageChangeListener - Stack Overflow 其中有个非常完美的解决方 ...

  6. 使用APOC技术从MYSQL数据库导数据到Neo4j图数据库(JDBC)

                                                     Neo4j 数据导入 一.安装与部署Neo4j 直接在官网下载安装包安装,解压即可. 2.mysql ...

  7. 2019-10-4-C#-极限压缩-dotnet-core-控制台发布文件

    title author date CreateTime categories C# 极限压缩 dotnet core 控制台发布文件 lindexi 2019-10-04 14:59:36 +080 ...

  8. JS数组 团里添加新成员(向数组增加一个新元素)只需使用下一个未用的索引,任何时刻可以不断向数组增加新元素。myarray[5]=88;

    团里添加新成员(向数组增加一个新元素) 上一节中,我们使用myarray变量存储了5个人的成绩,现在多出一个人的成绩,如何存储呢?  只需使用下一个未用的索引,任何时刻可以不断向数组增加新元素. my ...

  9. 为什么不直接使用socket ,还要定义一个新的websocket 的呢

    大致概念: TCP/IP 协议,是网络七层协议的第四层,本身没有长连接或短连接的区别: HTTP 是基于 TCP 协议之上的「短连接」应用层协议,它的出现极大简化了网络应用的实现门槛,丰富了应用: S ...

  10. linux 系统优化初始化配置

    一.系统优化配置 1.修改yum源  配置国内yum源 阿里云yum源地址 #CentOS 5.x wget -O /etc/yum.repos.d/CentOS-Base.repo http://m ...