• CALayer的锚点


    position是layer中的anchorPoint点在superLayer中的位置坐标。因此可以说, position点是相对suerLayer的,anchorPoint点是相对layer的,两者是相对不同的坐标空间的一个重合点。

    anchorPoint的默认值为 (0.5,0.5),也就是anchorPoint默认在layer的中心点。计算 position的值便可以用下面的公式计算:

    position.x = frame.origin.x + 0.5 * bounds.size.width;  
    position.y = frame.origin.y + 0.5 * bounds.size.height;  
    

    里面的0.5是因为anchorPoint取默认值,

      通用的公式应该是:

    position.x = frame.origin.x + anchorPoint.x * bounds.size.width;  
    position.y = frame.origin.y + anchorPoint.y * bounds.size.height;

     anchorPoint和position互不影响,受影响的只有frame。frame与anchorPoint和position的关系

    frame.origin.x = position.x - anchorPoint.x * bounds.size.width;  
    frame.origin.y = position.y - anchorPoint.y * bounds.size.height;  

     总结:

    1、position是layer中的anchorPoint在superLayer中的位置坐标。 
    2、frame、position与anchorPoint有以下关系:

    frame.origin.x = position.x - anchorPoint.x * bounds.size.width;  
    frame.origin.y = position.y - anchorPoint.y * bounds.size.height;  

     

  • 相关阅读:
    ArrayBlockingQueue
    mysql数据库引擎
    数据库主从复制,分库分表
    Java并发工具类-Semaphore,Exchanger
    分片策略
    kafka
    关于数据库设计
    生产者消费者模式

    Callable、Future和FutureTask
  • 原文地址:https://www.cnblogs.com/jinlongyu123/p/7485458.html
Copyright © 2020-2023  润新知