Date
1 - 4 of 4
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
|
|
Andy Lee
Two quick comments:
toggle quoted messageShow quoted text
- You want to set the subview's frame relative to the superview's bounds, not its frame. - You might want to experiment with a scratch app before making a lot of code changes at once in your existing app. Or, if possible, make your code changes incrementally, relaunch the app, fiddle with window size, and see if the changes look right. --Andy
On Wed, Sep 26, 2018, at 8:55 AM, Dave wrote:
Hi All,
|
|
Dave
Hi,
toggle quoted messageShow quoted text
Ok, yes, that was a typo, I released it needed to be after I posted, I was about to post that I’ve I’ve actually concocted a test app got it working using the bounds rect as a base. One thing I’ve noticed is that NSTextField doesn’t seem to Jive with isFlipped = YES, which seems odd and slightly annoying, anyone know why? Thanks a lot. All the Best Dave
On 26 Sep 2018, at 18:03, Andy Lee via Groups.Io <aglee@...> wrote:
|
|
Dave
HI,
toggle quoted messageShow quoted text
Just a quick message to say I’ve now got it working well using resizeWithOldSuperviewSize. Wanted to say thanks to everyone that helped. All the Best Dave
|
|