Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

center documentView in center of NSScrollView

How can I center my DocumentView (witch is subclass of NSOpenGLView) at NSScrollView?

Now it looks like this (gray area is NSScrollView bounds):

enter image description here

And I want it to look something like this:

enter image description here

like image 241
hockeyman Avatar asked Oct 03 '12 14:10

hockeyman


1 Answers

Subclass NSClipView and override -constrainBoundsRect: to return the centered rect. This is discussed at the the 45:30 mark in the fantastic presentation from WWDC 2013 - Session 215: Optimizing Drawing and Scrolling on OS X

like image 119
Andrew Avatar answered Nov 11 '22 05:11

Andrew