私のようなパスを描画するカスタムUIViewのを持っているので、UIColorとグラフィックスコンテキスト
- (void)drawRect:(CGRect)rect{
[[UIColor blackColor] setStroke];
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGContextSetFillColor(ctx, CGColorGetComponents(self.color));
CGContextFillPath(ctx);
UIBezierPath *thePath = [UIBezierPath bezierPath];
thePath.lineWidth = _lineWidth;
_center = CGPointMake(rect.size.width, rect.size.height);
[thePath moveToPoint:_center];
[thePath addArcWithCenter:_center radius:rect.size.width startAngle:M_PI endAngle:M_PI+degreesToRadians(_angle)clockwise:YES];
[thePath closePath];
[thePath fill];
}
マイカスタムUIViewのも、私はchangeColorを呼び出す場合、充填色
- (void) changeColor:(UIColor *) newColor {
self.color = [newColor CGColor];
[self setNeedsDisplay];
}
を変更する方法があります。方法は、
[UIColor redColor]
のような定義済みの色のいずれかを使用します。代わりに、私はそれをランダムに、白、赤と青の間の私のカスタムUIViewのちらつきの色を、そのような
UIColor* color = [UIColor colorWithRed:1.0f green:0.0f blue:0.0f alpha:1.0f];
などのカスタムカラーを与えることをしようとした場合。
それはなぜですか?
ありがとうございます!
うん、そうだった。厄介な小さなこと。 [The Documentation](https://developer.apple.com/library/mac/documentation/graphicsimaging/reference/CGContext/Reference/reference.html#//apple_ref/doc/uid/TP30000950-CH1g)のドキュメントに記載されているとおり-BCIJCGGJ)**使用する優先APIがCGContextSetFillColorWithColorになりました。** – tmpz
ありがとうございました:) – tmpz