How to Correctly Resize Views with Manual Layout


Dave
 

Hi All,

I’ve started move over to using the correct Manual Layout Methods as per my recent posts. The methods are:

resizeWithOldSuperviewSize


WindowTrackerView .view Property
SubviewA

All views have isFlipped override and returning YES.


Given that I want SubviewA to be inset 10 pixels from the top, left and right of the Superview and bottom to be the same as the superview, what code do I need to write?


For instance would the following work:

-(void) resizeWithOldSuperviewSize:(NSSize) theOldSuperviewSize
{
NSRect myRect;

[super resizeWithOldSuperviewSize: theOldSuperviewSize];

myRect.origin = self.superview.frame.origin.x + 10;
myRect.origin = self.superview.frame.origin.y + 10;
myRect.size.width = self.superview.frame.size.width - (10 *2);
myRect.size.height = self.superview.frame.size.height - 10;
self.frame = myRect;
}

I just want to be sure I’m on the right track before I start changing loads of code.

If anyone knows of a working example of using these methods, I’d be really grateful if they could point me to it!

Thanks in advance for any help.

All the Best
Dave

Join cocoa@apple-dev.groups.io to automatically receive all group messages.