Search code examples
objective-ccocoansscrollviewnsshadow

Subclassing an NSScrollView's DocumentView


How can one subclass an NSScrollView's DocumentView in order to do some custom drawing? I need to do some work with NSShadow inside of the scroll view.


Solution

  • The document view is just a normal view (subclass of NSView,) so all you have to do is to create a view, either programmatically or in Interface Builder, and set the scroll view's documentView property to the new view.

    You can set the property in a suitable awakeFromNib method, for instance.