I know CATextLayer has methods for setting font and fontsize, but not for every attribution e.g. linethrough or underline. So, I am trying to set an NSAttributedString to the string property of CATextLayer.
The documentation of CATextLayer states at the beginning:
The CATextLayer provides simple text layout and rendering of plain or attributed strings. The first line is aligned to the top of the layer.
and in the discussion of the string property:
The text must be an instance of NSString or NSAttributedString. Defaults to nil.
Based on this, using NSAttributedStrings should be fine. Unfortunately, the code snippet gives "-[NSConcreteAttributedString _isCString]: unrecognized selector sent to instance". Is there another way I am supposed to create the NSAttributedString?
The documentation of CATextLayer states at the beginning:
The CATextLayer provides simple text layout and rendering of plain or attributed strings. The first line is aligned to the top of the layer.
and in the discussion of the string property:
The text must be an instance of NSString or NSAttributedString. Defaults to nil.
Based on this, using NSAttributedStrings should be fine. Unfortunately, the code snippet gives "-[NSConcreteAttributedString _isCString]: unrecognized selector sent to instance". Is there another way I am supposed to create the NSAttributedString?
Code:
NSFont *font = [NSFont fontWithName:@"Palatino-Roman" size:14.0];
NSDictionary *attrsDictionary = [NSDictionary dictionaryWithObject:font
forKey:NSFontAttributeName];
NSAttributedString *attrString = [[[NSAttributedString alloc] initWithString:@"strigil"
attributes:attrsDictionary] autorelease];
CATextLayer *textlayer = ...//obtain layer
textlayer.string = @"aString"; //works
textlayer.string = attrString; //does not work