1
私が今直面している問題は、点と線をCAShapeLayerで描画した後、異なる矩形領域で変更することによって両方の色を変更する必要があることです。私が今設定した領域は、4つの部分を持ち、サンプルコードは以下の通りです。線を描く矩形領域によるCAShapeLayer層の色
- (void)drawChartWithRecord:(Chart *)Chart
lineWidth:(CGFloat)lineWidth
radius:(CGFloat)radius
interval:(CGFloat)interval
rect:(CGRect)rect {
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSaveGState(context);
float start_angle = 0;
float end_angle = (float) (2 * M_PI);
CAShapeLayer *avg = [CAShapeLayer layer];
avg.path = [UIBezierPath bezierPathWithArcCenter:CGPointMake(X,Y) radius:radius startAngle:start_angle endAngle:end_angle clockwise:YES].CGPath;
CGContextMoveToPoint(context, X, Y);
CGContextAddLineToPoint(context, pastX, pastY);
CGContextSetStrokeColorWithColor(context, LINE_COLOR);
CGContextSetLineWidth(context, lineWidth);
CGContextStrokePath(context);
[self.layer addSublayer:avg];
}
オンラインコードとドットコードがあります。しかし、同じCAShapeLayerにrectをインポートする方法が見つかりませんでした。私は
CAShapeLayer *mask = [CAShapeLayer layer];
などの新しい層を作る場合、私はサブレイヤの
[self.layer addSublayer:mask];
つを使用している場合はミックスだろう、と私は私の背景色を変更したくないという。問題があるでしょう
皆様のおかげです。