gpt4 book ai didi

ios - 如何加入圆角线

转载 作者:行者123 更新时间:2023-11-29 10:43:35 25 4
gpt4 key购买 nike

我有三个点,A、B、C,链接这三个点的代码如下

// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
// Drawing code
CGContextRef context = UIGraphicsGetCurrentContext();

NSArray *points = @[ [NSValue valueWithCGPoint:CGPointMake(10.0f, 15.0f)],
[NSValue valueWithCGPoint:CGPointMake(100.0f, 170.0f)],
[NSValue valueWithCGPoint:CGPointMake(190.0f, 100.0f)],
];

CGContextSetStrokeColorWithColor(context, [UIColor redColor].CGColor);
CGContextSetLineWidth(context, 2.0f);
CGContextSetLineJoin(context, kCGLineJoinRound);
CGContextSetLineCap(context, kCGLineCapRound);


for(int i = 0;i<points.count; ++i){

NSValue *pointValue = [points objectAtIndex:i];
CGPoint point = [pointValue CGPointValue];
if ( i == 0) {
CGContextMoveToPoint(context, point.x, point.y);
} else {
CGContextAddLineToPoint(context, point.x, point.y);
}
}
CGContextStrokePath(context);
}

enter image description here

但是,两条线的交界处是一个角,我需要用圆绳连接B点。如下图:

enter image description here

怎么做?

最佳答案

您拥有的是 2 条直线,您要求的是(可能是 2 条直线,由它们连接)一条圆弧/贝塞尔曲线。

查看使用 CGPathAddArcToPointCGPathAddCurveToPointCGPathAddQuadCurveToPoint

关于ios - 如何加入圆角线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23267242/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com