I don't know why, when I set the TAB view Controller's Transition property in Storyboard in OS X 10.11.5 and Xcode 7.3, the tab view Controller does not automatically follow the sub view C Ontroller's Preferred Content Size is used to animate gradients, so it can only be implemented on its own (including Propagate Title).
Current Storyboard settings:
Remember to turn off Propagate title because it doesn't have any use on my build, and it also affects the subsequent manual setting of the title via Delegate.
Step 1:
Subclass Tabview Controller, here is JZSettingsTabViewController , plus NSTabViewDelegate .
Step 2:
Implement the Protocol,
- (void)updateWindowSizeWithItem:(NSTabViewItem *)item{ NSWindow *window = self.view.window; NSSize contentSize = item.viewController.preferredMinimumSize; NSSize newWindowSize = [window frameRectForContentRect:(CGRect){CGPointZero, contentSize}].size; NSRect frame = [window frame]; frame.origin.y += frame.size.height; frame.origin.y -= newWindowSize.height; frame.size = newWindowSize; [self.view.window setFrame:frame display:YES animate:YES]; window.title = item.label;}
Step 3:
Since the above is preferredMinimumSize obtained by the size, then in the child View Controller implementation file Add this sentence, this time do not write Preferred Content Size:
- (CGSize)preferredMinimumSize{ return CGSizeMake(500, 400);}
Although this Size is not through the Storyboard set up a little too troublesome, but considering the Tabview Controller of each sub-VC is sure to achieve, also can be.
I'm here because I'm going to write the Setup interface so I use the Nstabviewcontroller and keep the window size fixed (by removing nsresizablewindowmask), if you need a window that can be Resize and keep tabs different The size of the switch animation,
NSSize contentSize = item.viewController.preferredMinimumSize;
This sentence can be modified appropriately, such as the expected size after the current stretch.
Manually implement the Nstabviewcontroller Rect Transition and Propagate title-b