Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Avizzv92

macrumors regular
Original poster
Mar 23, 2008
172
0
I have a custom NSView, when I adjust the frame's size the origin ends up moving. What I want is the view to be locked from the top left position so that when I re-size the view expands right and down while holding its position. Sorry if this is confusing, think of it like the left alignment for text sort of...

Also, this view is being created and displayed strictly with code and not Interface Builder.
 
I wasn't looking for it to re-size with the window, and the position still doesn't remain constant when I change the frame of the view.

Say I have a square that is on the edge of the window and its 50x50 in size. I make the new frame for it 250x250, it ends up enlarging it but half of it ends up expanding outside the view of the window. Hope this makes sense...
 
I think you're misunderstanding what the origin of the view actually is. In Cocoa, the origin is the bottom left. So when you adjust the view's height, the bottom of the view will stay the same and the top will change.

To do what you want to do, you need to adjust the frame height and origin at the same time.
 
If you override -isFlipped, the upper left corner of your view's bounds rectangle will be 0.0, 0.0 . However, if your view is drawing NSImages, you must set them to be flipped wholes you are drawing them in your view.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.