You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jun 20, 2023. It is now read-only.
你好,因為項目需求,發現线段/折线有兩個問題:
1.畫線段時,第一筆數值為空,無法執行。
2.在前後無數值,無發顯示當前一點。
以下是我的處理方式:
clockwise:(BOOL)clockwise{
UIBezierPath *bezierPath = [UIBezierPath bezierPath];
if (!lineArray.count) return bezierPath;
__block BOOL isMovePoint = YES;
__block CGPoint point = CGPointZero;//紀錄當前點
[lineArray enumerateObjectsUsingBlock:^(NSValue * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
if ([obj isKindOfClass:[NSValue class]]) {
if (isMovePoint) {
[bezierPath moveToPoint: [obj CGPointValue]];
point = [obj CGPointValue];
isMovePoint = NO; // 置空判断
}else{
[bezierPath addLineToPoint: [obj CGPointValue]];
point = CGPointZero;
}
}else{ // 记录下一个点需要移动,在無上下點時,畫出自己
if (point.x > 0 && point.y > 0) {
[bezierPath addLineToPoint: CGPointMake(point.x-0.5, point.y-0.5)];
point = CGPointZero;
}
isMovePoint = YES;
}
}];
if (!clockwise) bezierPath = [bezierPath bezierPathByReversingPath];// 逆时针绘制
return bezierPath;
}
The text was updated successfully, but these errors were encountered: