ios html 添加锚点,ios--calayer 锚点,   先设置好Position,再改变锚点

//图层内部是如何根据父图层和兄弟图层来控制位置和尺寸的

//layer position 设置Layer在父Layer中的(x,

y)坐标

//layer anchorPoint 为 Position

设置一个定点,相当于一个参照点,设置某个点在Pointsition上,被定位锚点的点处于Position上面,图形的非平移型形变都不会改变锚点,

相当于图形的把柄;

UIImage * image1 = [UIImage

imageNamed:@"11.png"];

UIImage * image2 = [UIImage

imageNamed:@"12.png"];

UIImage * image3 = [UIImage

imageNamed:@"13.png"];

UIImage * image4 = [UIImage

imageNamed:@"14.png"];

UIView * clockView = [[UIView

alloc] init];

[self.view

addSubview:clockView];

clockView.layer.position =

self.view.center;

clockView.layer.bounds

= CGRectMake(0, 0, 200, 200);

self.line1 = [[UIView alloc]

init];

self.line1.layer.position =

self.view.center;

self.line1.layer.backgroundColor = [UIColor redColor].CGColor;

self.line1.layer.bounds =

CGRectMake(0, 0, 4, 30);

self.line1.layer.anchorPoint

= CGPointMake(1, 1);

self.line2 = [[UIView alloc]

init];

self.line2.layer.position =

self.view.center;

self.line2.layer.bounds =

CGRectMake(0, 0, 4, 40);

self.line2.layer.anchorPoint

= CGPointMake(1, 1);

self.line2.layer.backgroundColor = [UIColor

yellowColor].CGColor;

self.line3 = [[UIView alloc]

init];

self.line3.layer.position =

self.view.center;

self.line3.layer.bounds =

CGRectMake(0, 0, 4, 50);

self.line3.layer.anchorPoint

= CGPointMake(0.5, 0.9);

self.line3.layer.backgroundColor = [UIColor

blackColor].CGColor;

[self.view

addSubview:self.line1];

[self.view

addSubview:self.line2];

[self.view

addSubview:self.line3];

[NSTimer scheduledTimerWithTimeInterval:1 target:self

selector:@selector(timeSec) userInfo:nil repeats:YES];

[NSTimer scheduledTimerWithTimeInterval:60 target:self

selector:@selector(timeMinu) userInfo:nil repeats:YES];

clockView.layer.contents =

(__bridge id)image1.CGImage;

self.line1.layer.contents

= (__bridge id)image2.CGImage;

self.line2.layer.contents

= (__bridge id)image3.CGImage;

self.line3.layer.contents

= (__bridge id)image4.CGImage;;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值