I am following Brad's answer to apply glow effect in my CALayer text.
Here is my code:
- (void)drawLayer:(CALayer *)theLayer inContext:(CGContextRef)context
{
UIGraphicsPushContext(context);
UIFont *font = [UIFont fontWithName:@"Verdana" size:11.0f];
CGRect rect = CGRectMake(theLayer.bounds.origin.x + 5, theLayer.bounds.origin.y + 5, theLayer.bounds.size.width - 10, theLayer.bounds.size.height - 10);
NSString * textToWrite = @"Some text";
UIColor *color = [ UIColor colorWithRed: (100.0f) green: (50.0) blue:(200.0f) alpha: 1.0f ];
CGContextSetFillColorWithColor(context, color.CGColor); //this has no effect!!!
CGContextSetShadowWithColor(context, CGSizeMake(0.0, 0.0), 2.0f, [UIColor greenColor].CGColor);
[textToWrite drawInRect:rect withFont:font
lineBreakMode:UILineBreakModeWordWrap alignment:UITextAlignmentLeft];
UIGraphicsPopContext();
}
I am getting a decent green glow here. However I want the text to have its own color too, apart from glow. For this I am using color variable here, along with CGContextSetFillColorWithColor
. But it seems to have NO effect. The text seems white, with green glow. I want text with main color = color and glow=green.
What should I do?