【发布时间】:2019-09-06 04:18:49
【问题描述】:
当试图在两点(imageViews)之间画一条线时,这条线是在另一个位置生成的。
这是我的代码:
- (void)drawLine:(UIView*)currentPoint endPoint:(UIImageView*)lastPoint{
UIBezierPath* path = [UIBezierPath bezierPath];
[path moveToPoint:currentPoint.center];
[path addLineToPoint:lastPoint.center];
CAShapeLayer *shapeLayer = [CAShapeLayer layer];
shapeLayer.path = [path CGPath];
shapeLayer.strokeColor = [[UIColor whiteColor] CGColor];
shapeLayer.lineWidth = 1.0;
[self.DrawView.layer addSublayer:shapeLayer];
}
【问题讨论】:
-
一切看起来都不错。你能分享/检查你传递给画线函数的CGPoints的值吗
标签: ios objective-c