Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSTextView and Core Animation drawing trouble

I'm having some trouble adding CA Layers on top of a NSTextView. I want to be able to add small "bubbles" (like in Xcode) to the text view, so i thought of doing it with core animation. When i enable layer backed mode in the views -awakeFromNib [self wantsLayer:YES], and add a empty CALayer as root layer [self setLayer:rootLayer], the content of the view gets completely destroyed with random garbage

Random garbage

If I set a background color on the root layer, that color shows nicely up. So somehow the textview behind the transparent layer doesnt redraw? Or is it a different problem?

EDIT: Here is an example project producing something similair (at least on 10.8)

Jonas

like image 544
Jonas Jongejan Avatar asked Dec 13 '25 12:12

Jonas Jongejan


1 Answers

It turns out that you can't replace the layer of the NSTextView, but only add sub layers. So replacing the line self.layer = rootLayer with [self.layer addSubLayer:rootLayer] works.
Replacing the layer breaks the NSTextView drawing.

like image 77
Jonas Jongejan Avatar answered Dec 15 '25 07:12

Jonas Jongejan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!