catextlayer

Resize CATextLayer to fit text on iOS

喜欢而已 提交于 2019-12-18 11:49:00
问题 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

How can i make my CATextLayer object Scrollable like UITextView?

不羁岁月 提交于 2019-12-13 08:26:33
问题 I have used CATextLayer for Displaying bold and Normal text together.Now some time i am getting long text from the Web Service response so i am not able to display complete text.Can any one please help me what should be the way to make CATextLayer object Scrollable like textview.Please suggest me any solution regarding this.I have also take reference from Here but it's not working for me. I am using this code: /* Create the text layer on demand */ if (!_textLayer) { _textLayer = [[CATextLayer

CATextLayer number of lines?

一曲冷凌霜 提交于 2019-12-11 18:28:05
问题 My CATextlayer support only 1 line otherwise the text is cut. trying to set text content like UILabel Behaviour... is it possible? set "number of lines" adjust text size by static CATextLayer frame CATextLayer *text_layer= [[CATextLayer alloc] init]; [text_layer setBackgroundColor:[UIColor clearColor].CGColor]; [text_layer setBackgroundColor:[UIColor blueColor].CGColor]; [text_layer setForegroundColor:layers.textColor.CGColor]; [text_layer setAlignmentMode:kCAAlignmentCenter]; [text_layer

How could one achieve a see-through text effect in iOS?

风格不统一 提交于 2019-12-11 08:09:22
问题 I would really like to achieve a see-through text style effect in my iOS app. It's pretty simple to create the desired effect in Photoshop, but I have no idea how this could be accomplished in code. The effect applied to text simply shows the background underneath the text, but it is darkened (or lightened) so that it is visible. There is no fill for the text at all, it just enhances the background where the text would be. This is what I want to obtain: This effect is kind of similar to the

How to get CATextLayer’s wrapping count in order to calculate height

旧街凉风 提交于 2019-12-10 11:41:57
问题 I am adding text incrementally to a wrapping CATextLayer in a UIScrollView . Each time I add text, I need to add height to the textLayer and to the scrollView’s contentSize , and adjust the scrollView’s contentOffset . (The user should be able to use the scrollView to review previous text, but when new text is added, I want to scroll down to it programmatically.) UIKit’s sizeWithFont: will treat the entire string as though it is on one line, so in order to calculate the height, I need to

CoreAnimation CALayer and CATextLayer combination

有些话、适合烂在心里 提交于 2019-12-09 18:29:53
问题 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

How to get CATextLayer’s wrapping count in order to calculate height

孤人 提交于 2019-12-07 03:51:27
I am adding text incrementally to a wrapping CATextLayer in a UIScrollView . Each time I add text, I need to add height to the textLayer and to the scrollView’s contentSize , and adjust the scrollView’s contentOffset . (The user should be able to use the scrollView to review previous text, but when new text is added, I want to scroll down to it programmatically.) UIKit’s sizeWithFont: will treat the entire string as though it is on one line, so in order to calculate the height, I need to multiple the size.height returned by the number of lines, as produced by the textLayer’s wrapping. Trouble

CATextLayer rotate?

房东的猫 提交于 2019-12-06 08:54:48
问题 This should really work, but is not: CATextLayer* textLayer = [CATextLayer layer]; textLayer.string = @"text"; [textLayer setValue:[NSNumber numberWithDouble:M_PI / 2.f forKey:@"transform.rotation"]; [self addSublayer:textLayer]; in fact, when i print the value at transform.rotation, it shows the correct answer. it just doesn't draw the textLayer rotated! NSLog(@"rotation %@", [textLayer valueForKey:@"transform.rotation"]); What am I doing wrong? 回答1: Try the following code: textLayer

CATextLayer wrapped sizeToFit?

橙三吉。 提交于 2019-12-05 03:26:04
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] . 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 you can then use to set the frame of your UILabel or whatever subclass of UIView that you're using. So,

CATextLayer rotate?

两盒软妹~` 提交于 2019-12-04 12:05:09
This should really work, but is not: CATextLayer* textLayer = [CATextLayer layer]; textLayer.string = @"text"; [textLayer setValue:[NSNumber numberWithDouble:M_PI / 2.f forKey:@"transform.rotation"]; [self addSublayer:textLayer]; in fact, when i print the value at transform.rotation, it shows the correct answer. it just doesn't draw the textLayer rotated! NSLog(@"rotation %@", [textLayer valueForKey:@"transform.rotation"]); What am I doing wrong? Try the following code: textLayer.transform = CATransform3DMakeAffineTransform(CGAffineTransformMakeRotation(M_PI_2)); instead of: [textLayer