【发布时间】:2015-02-19 04:07:55
【问题描述】:
基本上我需要实现的是需要在加号图标和带有动画的复选标记之间切换的自定义按钮。作为第一步,我尝试使用 CAShapeLayer 创建水平线并尝试旋转某个角度。我无法弄清楚其中有什么问题。
UIBezierPath *linePath = [UIBezierPath bezierPathWithRect:CGRectMake(0, 0,self.frame.size.width, 10)];
//shape layer for the line
CAShapeLayer *line = [CAShapeLayer layer];
line.backgroundColor = [UIColor redColor].CGColor;
line.path = [linePath CGPath];
line.fillColor = [[UIColor greenColor] CGColor];
line.frame = CGRectMake(0, 10, self.frame.size.width,10);
line.anchorPoint = CGPointMake(0.0, 0.5);
line.transform = CATransform3DMakeRotation(30, 0.0, 0.0, 1.0);
[self.layer addSublayer:line];
【问题讨论】:
标签: ios objective-c core-animation uibezierpath cashapelayer