Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CATextLayer not visible on video in iOS7

I'm working on a video app that generates a credits clip using a .mov resource as the background and a CATextLayer for the credits. The code works in iOS 5 and 6, but not in iOS 7 - ie: the clip gets generated but text does not appear.

I've tried using the code from the answer to this question (How can I add overlay text on a video, then re-encode it?), but the text in the CATextLayer still does not show up.

Why is iOS 7 behaving differently and how can I get it to work?

like image 935
Rob VS Avatar asked Jan 26 '26 01:01

Rob VS


1 Answers

After 2 days on this problem

CATextLayer *text = [CATextLayer layer];
text.string = @"Your Text";
text.frame = CGRectMake(0, 0, 320, 50);
CGFontRef font = CGFontCreateWithFontName((CFStringRef)@"HelveticaNeue-UltraLight");
text.font = font;
text.fontSize = 20;
text.foregroundColor = [UIColor whiteColor].CGColor;
[text display];
[aLayer addSublayer:text];
[aLayer display];

The secret is calling [CALayer display] method

like image 82
MAMN84 Avatar answered Jan 27 '26 17:01

MAMN84



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!