I am trying to add a CATextLayer
to UITableViewCell
. Problem is that text is rendering as black while I have already set its foregroundColor. Can someone tell me what I am missing? Thanks.
CATextLayer *buyPrice_port = [CATextLayer layer];
buyPrice_port.frame = CGRectMake(144, 42, 76, 21);
buyPrice_port.font = (__bridge CFTypeRef)([UIFont boldSystemFontOfSize:18]);
buyPrice_port.foregroundColor = [UIColor colorWithRed:0 green:190/255.0 blue:191/255.0 alpha:1.0].CGColor;
buyPrice_port.alignmentMode = kCAAlignmentCenter;
buyPrice_port.string = @"BAC";
[self.contentView.layer addSublayer:buyPrice_port];
This strange problem was due to the way I was setting my font. Instead it should be set like this:
buyPrice.font = CFBridgingRetain([UIFont boldSystemFontOfSize:18].fontName);
buyPrice.fontSize = 18;