zoukankan      html  css  js  c++  java
  • ios中图层的ancorPoint

    @interface MJViewController () {
        CALayer *_layer;
    }
    
    @end
    
    @implementation MJViewController
    
    - (void)viewDidLoad
    {
        [super viewDidLoad];
        
        CALayer *layer = [CALayer layer];
        layer.bounds = CGRectMake(0, 0, 100, 100);
        layer.position = CGPointMake(150, 150);
        layer.backgroundColor = [UIColor redColor].CGColor;
        
        // 定位点(1,1):当前图层右下角会在position所指定的位置上
    //anchorPoint决定的Position的位置
    layer.anchorPoint = CGPointMake(0, 0);//说明position的在左上角,坐标为(150,150) 宽度和高度分别100,100 _layer = layer; [self.view.layer addSublayer:layer]; } - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { _layer.anchorPoint = CGPointMake(1, 1);//说明position的右下角坐标为(150,150) 宽度和高度为100,100. }
  • 相关阅读:
    猜数字游戏
    发红包程序
    实现微信摇一摇部分功能
    计算1+1/2+1/3+....+1/100的值
    约瑟夫问题
    简易计时器
    简易学生管理系统
    文件加密解密
    分鱼问题
    分橘子问题
  • 原文地址:https://www.cnblogs.com/gcb999/p/3189226.html
Copyright © 2011-2022 走看看