美文网首页
iOS小知识(2016.07)—iOS frame、bounds

iOS小知识(2016.07)—iOS frame、bounds

作者: 宿于松下 | 来源:发表于2016-07-27 22:19 被阅读148次

iOS frame、bounds、anchorPoint、position以及transform(全文)

1 frame

layer相对其父坐标系的位置。包括矩形左上角点,矩形宽高。值得注意的是layer被旋转后的宽高。如下图所示,bounds是40*50,frame是62*64。

2 bounds

layer相对其内部坐标系的位置。

3 anchorPoint

layer的锚点(默认是{0.5, 0.5},即在layer的中部)相对其内部单位坐标系的位置。锚点就是layer旋转的中点。左上角是{0, 0},右下角是{1,1}。值得注意的是锚点的值可以比0小,比1大,例如{-0.5, 1.5},如此layer旋转可以围绕外部某个点

4 position

layer的锚点相对其外部坐标系的位置。

5 transform (3D变换)

6 CALayer的frame决定因素

view或者layer的frame其实不是一个独立的属性,它是由bounds、position和transform决定的虚拟属性。因此,一旦以上3个属性发生变化frame就会变化。相反地,一旦改变frame,那么bounds、position和transform也可能变化。

The frame is not really a distinct property of the view or layer at all; it is a virtual property, computed from the bounds, position, and transform, and therefore changes when any of those properties are modified. Conversely, changing the frame may affect any or all of those values, as well.

7 参考文档

Core Animation Programming Guide

《iOS Core Animation Advanced Techniques》

相关文章

  • iOS小知识(2016.07)—iOS frame、bounds

    iOS frame、bounds、anchorPoint、position以及transform(全文) 1 fr...

  • iOS 面试题目

    1、iOS frame和Bounds 以及frame和bounds区别2、 ios webView 加载HTML字...

  • iOS 常用布局方式之Frame

    级别: ★★☆☆☆标签:「iOS布局」「iOS frame」「iOS frame bounds」作者: Xs·H...

  • iOS纪录

    (1)View的Frame与Bounds区别 摘自 ios view的frame和bounds之区别(位置和大小)...

  • ios-坐标系统

    转—ios-坐标系统(详解UIView的frame、bounds跟center属性 1、概要 翻开ios官方开发文...

  • iOS --- Bounds, Frame

    Frame, Bounds,经常使用的字段,但是总会傻傻分不清。 先看一张图, 灰色视图,作为红色视图的父视图,红...

  • UIView的frame和bounds的区别

    UIView的frame和bounds的区别 UIView作为iOS里面常用的控件,它有两个属性Frame和bou...

  • UIView

    在iOS中,所有的控件都有大小(size)、位置(frame、bounds、center)、颜色等...这些共有属...

  • iOS:frame和bounds

    其实总结出来就两句话:frame:参照坐标系是 父视图中的(0, 0);bounds:参照坐标系为其自身,对于其子...

  • iOS Frame vs Bounds

    According to official iOS Documentation about UIView, Fra...

网友评论

      本文标题:iOS小知识(2016.07)—iOS frame、bounds

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