zoukankan      html  css  js  c++  java
  • iOS position(位置)和anchorPoint(锚点)

    参考自:

    https://www.jianshu.com/p/0dfccd073ae0

    https://www.cnblogs.com/kingbo/p/7162364.html

     

        CALayer *MamiLayer = [CALayer layer];
        MamiLayer.backgroundColor = [UIColor orangeColor].CGColor;
        MamiLayer.bounds = CGRectMake(0, 0, 100, 100);
        MamiLayer.position = CGPointMake(self.view.frame.size.width / 2, self.view.frame.size.height /2);
        MamiLayer.anchorPoint=CGPointMake(0, 1);
        [self.view.layer addSublayer:MamiLayer];
        NSLog(@"MamiLayer.position =>( %f,%f )",MamiLayer.position.x,MamiLayer.position.y);
        
        CALayer *MamiLayer2 = [CALayer layer];
            MamiLayer2.backgroundColor = [UIColor redColor].CGColor;
            MamiLayer2.bounds = CGRectMake(0, 0, 100, 100);
            MamiLayer2.position = CGPointMake(self.view.frame.size.width / 2, self.view.frame.size.height /2);
        //    MamiLayer.anchorPoint=CGPointMake(0.3, 0.3);
            [self.view.layer addSublayer:MamiLayer2];
    

    1. position相当于UIView视图中的center,是layer视图的中心点。

    2. 确实设置了anchorPoint , position 是不会改变的。

    3. 我的理解就是,设置anchorPoint在哪,就把anchorPoint 放到 position 的位置。就得到结果视图的位置。这是个逆推的过程。

    此文仅为鄙人学习笔记之用,朋友你来了,如有不明白或者建议又或者想给我指点一二,请私信我。liuw_flexi@163.com/QQ群:582039935. 我的gitHub: (学习代码都在gitHub) https://github.com/nwgdegitHub/
  • 相关阅读:
    java基础知识(一)- 数据类型
    Java基础知识-去重
    java基础知识-冒泡排序
    Java排序方法sort的使用详解
    Java面试题-字符串操作
    Map.Entry遍历Map
    Java中String的用法
    Java循环控制语句-switch
    API文档打开显示'已取消到该网页的导航'的解决方法
    CentOS6.5 安装snort
  • 原文地址:https://www.cnblogs.com/liuw-flexi/p/12787309.html
Copyright © 2011-2022 走看看