I'd like to add some custom text highlighting to my NSTextView, so I added the
following code to the NSTextView init method:
CALayer *aLayer = [CALayer layer];
[self setWantsLayer: YES];
[self setLayer: aLayer];
Then I add the highlighting for a particular text range (aRange):
self.layer.backgroundColor = CGColorCreateGenericRGB (0.2, 0.2, 0.1,
1.0);
self.layer.frame = [self.layoutManager boundingRectForGlyphRange:
aRange inTextContainer: self.textContainer];
But it looks all garbled for the while view, not for the range, and I see the
Xcode window text behind it.
What should I do to make this work?
attributes = [NSDictionary dictionaryWithObjectsAndKeys: [NSColor redColor,
NSBackgroundColorAttributeName, nil];
[self layoutManager] addTemporaryAttributes: attributes forCharacterRange:
aRange]; works, but I'd like to have some more control on how the text
highlighting is drawn.
- Koen.
_______________________________________________
Cocoa-dev mailing list ([email protected])
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [email protected]