我正在尝试绘制源自一个点(UIView 的中心)的线条,如下所示:
- (void)drawRect:(CGRect)rect {
UIBezierPath *path = [self createPath];
[path stroke];
path = [self createPath];
CGAffineTransform rot = CGAffineTransformMakeRotation(2 * M_PI/16);
[path applyTransform:rot];
[path stroke];
path = [self createPath];
rot = CGAffineTransformMakeRotation( 2 * M_PI/8);
[path applyTransform:rot];
[path stroke];
}
- (UIBezierPath *) createPath {
UIBezierPath *path = [UIBezierPath bezierPath];
CGPoint start = CGPointMake(self.bounds.size.width/2.0f, self.bounds.size.height/2.0f);
CGPoint end = CGPointMake(start.x + start.x/2, start.y);
[path moveToPoint:start];
[path addLineToPoint:end];
return path;
}
这个想法是绘制同一条线并应用旋转(围绕中心 = 线的起点)。结果是这样的:
https://dl.dropbox.com/u/103998739/bezierpath.png
两条旋转的线似乎也以某种方式偏移。图层锚点默认为 0.5/0.5。我究竟做错了什么 ?