//图层内部是如何根据父图层和兄弟图层来控制位置和尺寸的
//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;;