Interface Builder: What are the UIView's Layout iOS 6/7 Deltas for?
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? |
|||||
|
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 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. |
|||||||||
|
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 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:
The key name
Whilst the values stored in the .xib doesn't correspond to the quoted values directly, there is a correlation between them.
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 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 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, 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. |
|||||||||||||
|
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 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. |
|||||
|
最新文章
- freemarker内置函数和用法
- redis 笔记06 发布与订阅、事务、慢查询日志、监视器
- PHP 长字符串替换操作性能(替换多换注释的代码)
- Spring(3.2.3) - Beans(7): 延迟实例化
- NopCommerce架构分析之参考资料
- android 自动化(1)
- 基于visual Studio2013解决C语言竞赛题之1019填数
- HTTPS的学习
- OpenCV-Python教程(5、初级滤波内容)
- ./startup.sh: Permission denied
- VS2015企业版和专业版永久密匙
- Spring3 MVC
- 零基础入门学习javase,应该怎么学?这是我给你的一个建议
- Collections集合工具类
- Ikki's Story IV - Panda's Trick POJ - 3207(水2 - sat 在圈内 还是 在圈外)
- MySQL中case then用法
- javascript-时间戳
- static关键字的功能
- lucene基本原理
- String StringBuffer stringbuilder 区别
热门文章
- P2763 试题库问题 (网络流 最大流)
- SpringCloud网关无法加载权限及IP黑名单白名单
- Jenkins 自动部署
- QT之QSettings 学习
- 「APIO 2019」桥梁
- java_缓冲流(文件内容排序)
- 试做Chrome插件——whatweb的chrome插件(从老博客转)
- bootstrap table 实现固定悬浮table 表头并可以水平滚动
- CF596D Wilbur and Trees
- Type.GetType(string.contains(','))