文章目录
  1. 1. 锚点

UIView有三个比较重要的布局属性:frameboundscenter,对应到CALayer叫做frameboundsposition

  • frame代表图层的外部坐标,也就是父图层上占据的空间
  • bounds内部坐标,{0,0}是图层的左上角
  • centerposition都代表了相对父图层的anchorPoint所在的位置

锚点

默认的anchorPoint位于图层的中点,所以图层将会以这个点为中心放置,anchorPoint属性并没有暴露个UIView接口暴露出来,这也就是视图position属性被叫做center,但是图层的anchorPoint可以被移动

anchorPoint用单位坐标来描述,图层左上角是{0,0},右下角是{1,1},默认坐标是{0.5,0.5},anchorPoint也可以通过指定x和y值小于或大于1,使它放置在图层范围之外。

文章目录
  1. 1. 锚点