catextlayer

CATextLayer textcolor is always black

不想你离开。 提交于 2020-01-24 18:14:41
问题 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

CATextLayer doesn't appear in an AVMutableComposition when running from a unit test

微笑、不失礼 提交于 2020-01-03 07:14:09
问题 EDIT: The strangest thing: it seems that when running this code from a full app everything works, but I was always running the creation of the movie from my unit tests, and only there it didn't work. Trying to figure out why is that... I'm trying to combine video + audio + text using AVMutableComposition and export it to a new video. My code is based on the AVEditDemo from WWDC '10 I added a purple background to the CATextLayer so I can know for a fact it is exported to the movie, but no text

Is it possible to add a UILabel or CATextLayer to a CGPath in Swift, similar to Photoshop's type to path feature?

血红的双手。 提交于 2020-01-02 00:12:59
问题 I would like to add text, whether it be a UILabel or CATextLayer to a CGPath . I realize that the math behind this feature is fairly complicated but wondering if Apple provides this feature out of the box or if there is an open-source SDK out there that makes this possible in Swift. Thanks! Example: 回答1: You'll need to do this by hand, by computing the Bezier function and its slope at each point you care about, and then drawing a glyph at that point and rotation. You'll need to know 4 points

CATextLayer wrapped sizeToFit?

六月ゝ 毕业季﹏ 提交于 2019-12-22 04:17:09
问题 If I set textLayer.wrapped = YES , how do I resize textLayer to contain the wrapped text? I.e., how do I get the new height of the textLayer ? Basically, I want something like -[UILabel sizeToFit] . 回答1: The first thing you need to do is get the size of the text. Thankfully, the NSString UIKit Additions Reference offers a method to do exactly that: - (CGSize)sizeWithFont:(UIFont *)font constrainedToSize:(CGSize)size lineBreakMode:(UILineBreakMode)lineBreakMode That will give you a CGSize that

Add text to Video for specific time in iOS

随声附和 提交于 2019-12-20 07:26:47
问题 I am creating a video based application where I have to select any video from local gallery and have to add a text using CATextLayer over the Video. For this I am using below code: - (void) createWatermark:(UIImage*)image video:(NSURL*)videoURL { if (videoURL == nil) return; AVURLAsset* videoAsset = [[AVURLAsset alloc]initWithURL:videoURL options:nil]; AVMutableComposition* mixComposition = [AVMutableComposition composition]; AVMutableCompositionTrack* compositionVideoTrack = [mixComposition

Resize CATextLayer to fit text on iOS

倾然丶 夕夏残阳落幕 提交于 2019-12-18 11:51:07
问题 All my research so far seems to indicate it is not possible to do this accurately. The only two options available to me at the outset were: a) Using a Layout manager for the CATextLayer - not available on iOS as of 4.0 b) Use sizeWithFont:constrainedToSize:lineBreakMode: and adjust the frame of the CATextLayer according to the size returned here. Option (b), being the simplest approach, should work. After all, it works perfectly with UILabels. But when I applied the same frame calculation to