Re: Centering a view in an NSScrollView
Re: Centering a view in an NSScrollView
- Subject: Re: Centering a view in an NSScrollView
- From: Christopher B Hamlin <email@hidden>
- Date: Sun, 20 Jan 2002 02:00:29 -0500
On Saturday, January 19, 2002, at 10:32 PM, Dustin Mierau wrote:
I have a view in an NSScrollView, when the contentSize of the
scrollview is larger than my view I want my view to appear centered
within the scrollview, even as the scrollview is being resized. Right
now it is tagged to the bottom left. I know I can return YES from the
isFlipped method to tag it to the top left, but like I said, I want it
centered. There does not seem to be a good way to do this, any ideas?
I had to work through something similar (zooming in/out in an
NSScrollView
on the visible center). If you want to know how to do that, I can tell
you for sure.
For this, off the top of my head, you might be able to keep track of
the
contentView's bounds and adjust for any changes in size by moving
the origin. If you NSLog the contentView's bounds in your drawRect you
might be able to figure out how to keep things centered.
Regards,
Chris Hamlin