Compile Swift Logo

It's all about Tab's

I have been trying to add a settings panel to my MetaMaker macOS application, everything I tried always opened a new window rather than replacing the current window content.

It turns out that I needed to think different. Thanks to a member of the iOS Folks Slack channel, they pointed me to using tabbed based content without a tab navigator.

This allows me to switch content tabs in code, but without the need to show a tab navigation bar. This was a huge shift in my thinking and greatly appreciated.

In the screenshot below I have highlighted the tab section in red and each tab in Green.

To switch between the tabs in code, I created two simple functions that use the tab index to identify which I want displayed.

    // MARK: Menu Items

    @IBAction func showSettingsWindow(_ sender: Any) {
        tabContainer.selectTabViewItem(at: 1)
    }

    @IBAction func showPostCreatorWindow(_ sender: Any) {
        tabContainer.selectTabViewItem(at: 0)
    }

With that all in place, it just works rather nicely.

Back

Copyright 2024 PeterWitham

Facebook Instagram Twitter Mastodon GitHub