Reputation: 1183
How can I center my DocumentView
(witch is subclass of NSOpenGLView) at NSScrollView
?
Now it looks like this (gray area is NSScrollView bounds):
And I want it to look something like this:
Upvotes: 8
Views: 758
Reputation: 7719
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
Upvotes: 2
Reputation: 105
Use an intermediate NSView which has the document view centered in it (set its frame accordingly and probably set layout constraints the way it should behave). Put that view in the scroll view.
Upvotes: 0