When I tried to add image as CATextLayer content, text is not shown. Only image is shown. This is my code which I have placed in viewDidLoad()
method,
UIImage *uiimage = [UIImage imageNamed:@"flying.png"];
CATextLayer *textLayer = [CATextLayer layer];
textLayer.frame = CGRectMake(144, 42, 76, 21);
textLayer.font = CFBridgingRetain([UIFont boldSystemFontOfSize:18].fontName);
textLayer.fontSize = 18;
textLayer.foregroundColor = [UIColor redColor].CGColor;
textLayer.backgroundColor = [UIColor yellowColor].CGColor;
textLayer.alignmentMode = kCAAlignmentCenter;
textLayer.string = @"Hello world";
textLayer.contents = (id)uiimage.CGImage;
[self.view.layer addSublayer:textLayer];
Please help to solve the issue.