Auto Layout

XCode5+

Auto Layout Concepts

核心的概念是约束。

Constraint Basics

  • Constant value
  • Relation
  • Priority level

约束是累积的,重复定义一个按钮的宽度的约束不会覆盖上一个约束。因此你需要移除上一个约束。

Working with Constraints in Interface Builder(IB)

Interface Builder 简称IB

Adding Constraints

Control-Drag

当然我喜欢右击拉开,一样的效果。

Aligh and Pin 菜单

这个菜单在右下角。

Editing Constraints

Deleting Constraints

Canvas or in the outline view

Working with Auto Layout Programmatically

You can add constraints programmatically

Creating Constraints Programmatically

NSDictionary *viewsDictionary =                NSDictionaryOfVariableBindings(self.button1, self.button2);NSArray *constraints =        [NSLayoutConstraint constraintsWithVisualFormat:@"[button1]-[button2]"                            options:0 metrics:nil views:viewsDictionary];

Resolving Auto Layout Issues

On the canvas. Misplaced or ambiguous constraints are shown in orange, conflicting constraints are red,and red dotted frames show the predicted runtime positions of misplaced or ambiguous views.

  • Resolving View Misplacement
  • Resolving Constraint Conflicts

    Auto Layout by Example

未完待续

Auto Layout的更多相关文章

  1. 【Auto Layout】Xcode6及以上版本,创建Auto Layout 约束时产生的一些变化【iOS开发教程】

    [#Auto Layout#]Xcode6创建Auto Layout 约束时产生的一些变化     通过两个小Demo来展示下变化: Demo1需求: 为控制器的根视图(图中的“控制器View”)的子 ...

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

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

  3. 手写代码自动实现自动布局,即Auto Layout的使用

    手写代码自动实现自动布局,即Auto Layout的使用,有需要的朋友可以参考下. 这里要注意几点: 对子视图的约束,若是基于父视图,要通过父视图去添加约束. 对子视图进行自动布局调整,首先对UIVi ...

  4. 使用Auto Layout中的VFL(Visual format language)--代码实现自动布局【转】

    本文将通过简单的UI来说明如何用VFL来实现自动布局.在自动布局的时候避免不了使用代码来加以优化以及根据内容来实现不同的UI. 一:API介绍 NSLayoutConstraint API 1 2 3 ...

  5. 转载自@机智的新手:使用Auto Layout中的VFL(Visual format language)--代码实现自动布局

    本文将通过简单的UI来说明如何用VFL来实现自动布局.在自动布局的时候避免不了使用代码来加以优化以及根据内容来实现不同的UI. 一:API介绍 NSLayoutConstraint API 1 2 3 ...

  6. ios auto layout demystified (二)

    Constraints Constraint Types Layout constraints (NSLayoutConstraint class, public)—这些规则指定了view的几何学.他 ...

  7. ios auto layout demystified (一)

    Ambiguous Layout 在开发过程中,你可以通过调用hasAmbiguousLayout 来测试你的view约束是否足够的.这个会返回boolean值.如果有一个不同的frame就会返回ye ...

  8. iOS Auto Layout

    Auto Layout是什么 Auto Layout是一个基于constraint(约束)的布局系统,它根据UI元素之间约束关系来调整UI元素的位置和大小. Auto Layout解决什么问题 更容易 ...

  9. WWDC2016 Session笔记 - Xcode 8 Auto Layout新特性

    目录 1.Incrementally Adopting Auto Layout 2.Design and Runtime Constraints 3.NSGridView 4.Layout Feedb ...

随机推荐

  1. 转:JQuery读写Cookie

    Cookies是一种能够让网站服务器把少量数据储存到客户端的硬盘或内存,或是从客户端的硬盘读取数据的一种技术.当你浏览某网站时,你硬盘上会生产一个非常小的文本文件,它可以记录你的用户ID.密码.浏览过 ...

  2. 和我一起学python,初识python (life is short ,we need python)

    作者:tobecrazy  出处:http://www.cnblogs.com/tobecrazy 欢迎转载,转载请注明出处.thank you! 由于项目需要(并非因为life is short), ...

  3. percona-toolkit 之 【pt-slave-delay】说明

    摘要: 在主从复制的架构中,正常情况下主上操作的记录也会在从上进行操作,虽说是异步复制,但操作会“实时”的同步到从.比如在主上不小心误操作了,还没等反应过来从上也会马上执行误操作,后期只有通过二进制或 ...

  4. [第三方]SCNetworkReachability 获取网络状态控件使用方法

    用Cocoa Pods导入控件以后 直接导头文件 复制以下代码 [SCNetworkReachability host:@"github.com" reachabilityStat ...

  5. 修改UINavigationController返回按钮颜色

    系统默认颜色是蓝色的 视觉效果非常难看 在push进的ViewController中写 //修改UINavigationController的文字颜色 self.navigationControlle ...

  6. 【leetcode】 Palindrome Partitioniong (middle) (*^__^*)

    Given a string s, partition s such that every substring of the partition is a palindrome. Return all ...

  7. 【leetcode】Remove Nth Node From End of List(easy)

    Given a linked list, remove the nth node from the end of list and return its head. For example, Give ...

  8. [Android] adb 命令 dumpsys activity , 用来看 task 中的activity。 (uninstall virus)

    用“adb shell dumpsys activity”命令再来查看一下系统运行的的任务,就会看到: ACTIVITY MANAGER ACTIVITIES (dumpsys activity ac ...

  9. October 7th 2016 Week 41st Friday

    The land didn't move, but moved; the sea was not still, yet was still. 大地止而亦行,大海动而亦静. Remember that ...

  10. oracle sqlplus存储过程控制台输出信息

    如果你是使用PL/sql工具,在command 窗口下执行set serveroutput on 然后exec sp;可以看到了或者在sqlplus 中执行上面的代码