A package for make easier implementing a structure of settings / preferences UI for macOS AppKit-based apps.
Basically only the close button works in a setting window, but depending on the pane, the zoom button can also be enabled.
I have provided an option to close the settings window with the Escape key.
The settings Window supports autosave via UserDefaults. The last window position can be restored automatically.
The base view controller for setting pane. You can use this class to customize your own.
WindowController for Settings window. You do not need to edit.
WindowController’s contentViewController. You do not need to edit.
Use SwiftPM.
To set panes of settings window, there are two ways of them.
var settingsWindowController: SettingsWindowController!
---
settingsWindowController = .init(with: [
SettingsPaneViewController(tabName: "General",
tabImage: NSImage(systemSymbolName: "gearshape", accessibilityDescription: nil),
tabIdentifier: "general",
isResizableView: false),
SettingsPaneViewController(tabName: "View",
tabImage: NSImage(systemSymbolName: "eyeglasses", accessibilityDescription: nil),
tabIdentifier: "view",
isResizableView: true),
SettingsPaneViewController(tabName: "Extensions",
tabImage: NSImage(systemSymbolName: "puzzlepiece.extension", accessibilityDescription: nil),
tabIdentifier: "extensions",
isResizableView: false),
SettingsPaneViewController(tabName: "Advanced",
tabImage: NSImage(systemSymbolName: "gearshape.2", accessibilityDescription: nil),
tabIdentifier: "advanced",
isResizableView: false),
])
func set(panes: [SettingsPaneViewController])
func add(pane: SettingsPaneViewController)
func insert(pane: SettingsPaneViewController, at index: Int)
func insert(tabViewItem: NSTabViewItem, at index: Int)
To remove any pane, use NSTabViewController’s methods.
There are properties of tab item in SettingsPaneViewController.
tabName
- Alias of
NSViewController.title
.
- Alias of
tabImage
tabIdentifier
- Should set to a unique name.
There is a property in SettingsPaneViewController. Set true to allow window resizing only while the pane is active. The default value is false. Check the Demo implementation and Main
Storyboard file.
isResizableView
See LICENSE for details.