ストーリーボードから UILabel を描画するのに問題があります。常に空白です。ラベルはプロパティ self.rainbowCircle として定義されています。ビューコントローラーの設定は次のとおりです。
self.rainbowCircle.layer.name = @"Rainbow Layer";
self.rainbowCircle.layer.delegate = self;
[self.rainbowCircle.layer setNeedsDisplay];
ここに drawLayer: inContext: があります。
- (void) drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx
{
CGContextSaveGState(ctx);
if ([layer.name isEqualToString:@"Rainbow Layer"]) {
NSLog(@"here");
NSArray *rainbowColorsArray = [NSArray arrayWithObjects:
(id)[UIColor colorWithHue:0.0 saturation:1.0 brightness:1.0 alpha:1.0].CGColor,
(id)[UIColor colorWithHue:1.0*360.0/6.0/360.0 saturation:1.0 brightness:1.0 alpha:1.0].CGColor,
(id)[UIColor colorWithHue:2.0*360.0/6.0/360.0 saturation:1.0 brightness:1.0 alpha:1.0].CGColor,
(id)[UIColor colorWithHue:3.0*360.0/6.0/360.0 saturation:1.0 brightness:1.0 alpha:1.0].CGColor,
(id)[UIColor colorWithHue:4.0*360.0/6.0/360.0 saturation:1.0 brightness:1.0 alpha:1.0].CGColor,
(id)[UIColor colorWithHue:5.0*360.0/6.0/360.0 saturation:1.0 brightness:1.0 alpha:1.0].CGColor,
(id)[UIColor colorWithHue:1.0 saturation:1.0 brightness:1.0 alpha:1.0].CGColor,
nil];
CGColorSpaceRef deviceRGB = CGColorSpaceCreateDeviceRGB();
CGGradientRef gradient = CGGradientCreateWithColors(deviceRGB, (__bridge CFArrayRef) (rainbowColorsArray), NULL);
CGContextDrawRadialGradient(ctx, gradient, self.rainbowCircle.center, 0.0, self.rainbowCircle.center, self.rainbowCircle.bounds.size.width/2.0, kCGGradientDrawsBeforeStartLocation);
CGColorSpaceRelease(deviceRGB);
CGGradientRelease(gradient);
} else {
[self drawPalette:self.currentPalette inLayer:layer inContext:ctx];
}
CGContextRestoreGState(ctx);
}
私はかなり長い間これを見つめてきましたが、何が欠けているのかわかりません。NSLog は表示されます。任意のガイダンスをいただければ幸いです。