美文网首页JC专题
iOS UIKit 学习(一):继承结构、元素之间的约束

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

作者: 不笑猫为什么要笑 | 来源:发表于2016-03-31 23:59 被阅读0次

想法、问题

在学习的第一天,不停在用 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 学习(一):继承结构、元素之间的约束

    本文链接:https://www.haomeiwen.com/subject/gztylttx.html