Manually implement the Nstabviewcontroller Rect Transition and Propagate title-b

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.