catextlayer

CoreAnimation CALayer and CATextLayer combination

有些话、适合烂在心里 提交于 2019-12-04 10:06:27
I'am just playing around with CA lately. Now I am kind of stuck. This is the thing I want to animate: As for now I already got the circle animation working. I subclassed CALayer to make the animation. I really don't know where to go from here. Where do I have to add the sublayer of CATextLayer? How do I animate both at the same time so it looks like the text with its line is sticking at the circle end? If you need some code or anything else let me know. I would be really happy to get some help here :-) Thanks a lot! I was able to do what you are asking for below. Code is very rough, just spent

Unwanted Vertical Padding from iOS 6 on CATextLayer

北城余情 提交于 2019-12-03 13:50:39
问题 Background: I started my project in iOS 5 and built out a beautiful button with layer. I added a textLayer onto the button and center it using the following code: float textLayerVerticlePadding = ((self.bounds.size.height - fontSize) /2); textLayer = [[CATextLayer alloc]init]; [textLayer setFrame:CGRectOffset(self.bounds, 0, textLayerVerticlePadding)]; It works great and looks dead center until iOS 6. Problem: iOS 6 added a space (padding) between the topmost bound and the text in textLayer.

Unwanted Vertical Padding from iOS 6 on CATextLayer

烂漫一生 提交于 2019-12-03 03:50:20
Background: I started my project in iOS 5 and built out a beautiful button with layer. I added a textLayer onto the button and center it using the following code: float textLayerVerticlePadding = ((self.bounds.size.height - fontSize) /2); textLayer = [[CATextLayer alloc]init]; [textLayer setFrame:CGRectOffset(self.bounds, 0, textLayerVerticlePadding)]; It works great and looks dead center until iOS 6. Problem: iOS 6 added a space (padding) between the topmost bound and the text in textLayer. This upsets the calculation above. Is there a way to make sure that iOS 6 does not? because I would

How to change the text color in a CATextLayer in Swift

爷,独闯天下 提交于 2019-12-01 04:15:19
问题 I want to change the text color of a CATextLayer. This does not work myTextLayer.textColor since there is no such property. I also got no response by setting the foreground color textLayer.foregroundColor = someColor.CGColor when the text layer is set up as follows let myAttribute = [ NSFontAttributeName: UIFont(name: mongolFontName, size: fontSize )! ] let attrString = NSMutableAttributedString(string: textLayer.displayString, attributes: myAttribute ) textLayer.frame = myFrame textLayer

CATextLayer + NSAttributtedString + CTParagraphStyleRef

雨燕双飞 提交于 2019-11-30 15:57:30
问题 I want to have some text with a custom line-spacing, so I wrote an attribute string with CTParagraphStyleAttributte and pass it to my CATextLayer : UIFont *font = [UIFont systemFontOfSize:20]; CTFontRef ctFont = CTFontCreateWithName((CFStringRef)font.fontName, font.pointSize, NULL); CGColorRef cgColor = [UIColor whiteColor].CGColor; CGFloat leading = 25.0; CTTextAlignment alignment = kCTRightTextAlignment; // just for test purposes const CTParagraphStyleSetting styleSettings[] = {

Resize CATextLayer to fit text on iOS

流过昼夜 提交于 2019-11-30 04:44:49
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 CATextLayer, the frame was always turning out to be a bit bigger than expected or needed. As it turns