iOS UIKit 学习(一):继承结构、元素之间的约束

想法、问题

在学习的第一天,不停在用 Storyboard 拖拉着一些组件去完成书本里的 Auto Layout 布局,目前有好两个问题:

  1. Attributes inspector 中有好几块设置组件的类,不同的组件在面板中的类不一
  2. Auto Layout 那一堆约束来约束去的,都是些啥?

组件类

现在我的容器中有两个不同的组件(控件)

  • UILabel
  • UIButton

在它们的 Attributes inspector 中,UILabel 只有两个设置属性的地方,Label 和 View ,而 UIButton 有三个,Button 、Controller 和 View 。很神奇吧,然后我去 Apple Developer Library 查到一个文档 UIView Class Reference ,找到了他们的继承关系。

 - NSObejct
  - UIResponder
    - UIView
        UILabel
    - UIView
      - UIControl
          UIButton

看,很明显吧,这样看就觉得 Attributes inspector 里面设置属性的类,就像一层一层的继承结构一样,这么理解应该没有问题哈。

约束

这里未完待续

你可能感兴趣的:(iOS UIKit 学习(一):继承结构、元素之间的约束)