gpt4 book ai didi

ios - 重用 UIBezierPath 对象

转载 作者:行者123 更新时间:2023-11-29 02:13:01 25 4
gpt4 key购买 nike

我想在圆弧下画一个圆弧和圆,我正在使用 UIBezierPath 来做。

但是我只想使用一个 bezierPath,下面的代码似乎是虚拟的。如何将两个 beizerPath 合并为一个并绘制相同的图表?

- (void)drawBackGround {
UIBezierPath *bgPath = [UIBezierPath bezierPath];
UIColor *color = [UIColor colorWithHex:BG_ARC_COLOR];
[color set];
[bgPath addArcWithCenter:self.center radius:BG_RADIUS startAngle:START_ANGLE endAngle:END_ENGLE clockwise:ANTY_CLOCK_WISE];
bgPath.lineWidth = BG_ARC_WIDTH;
bgPath.lineCapStyle = kCGLineCapRound;
bgPath.lineJoinStyle = kCGLineCapRound;
[bgPath stroke];
UIBezierPath *circylePath = [UIBezierPath bezierPath];
[circylePath moveToPoint:self.center];
[circylePath addArcWithCenter:self.center radius:BG_CIRCYLE_RADIUS startAngle:0 endAngle:2 * M_PI clockwise:CLOCK_WISE];
[circylePath addLineToPoint:self.center];
[circylePath fill];
}

最佳答案

试一试:

UIBezierPath *bgPath = [UIBezierPath bezierPath];
UIColor *color = [UIColor colorWithHex:BG_ARC_COLOR];
[color set];
[bgPath addArcWithCenter:self.center radius:BG_RADIUS startAngle:START_ANGLE endAngle:END_ENGLE clockwise:ANTY_CLOCK_WISE];
bgPath.lineWidth = BG_ARC_WIDTH;
bgPath.lineCapStyle = kCGLineCapRound;
bgPath.lineJoinStyle = kCGLineCapRound;
[bgPath stroke];

[bgPath removeAllPoints];

[bgPath moveToPoint:self.center];
[bgPath addArcWithCenter:self.center radius:BG_CIRCYLE_RADIUS startAngle:0 endAngle:2 * M_PI clockwise:CLOCK_WISE];
[bgPath addLineToPoint:self.center];
[bgPath fill];

关于ios - 重用 UIBezierPath 对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29072604/

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