Inspector Panes for macOS
A Cocoa, auto-layout managed view to build and manage inspector panes equivalent to the inspectors in Apple's Pages and Numbers applications.
I've implemented and fought with this on a number of different projects and decided to make a drop-in class that would do everything that I wanted. This class is fully autolayout managed.
I really like Apple 'Pages' implementation which allows having a header view which can be used to configure items even when the pane itself is hidden. A good example of this is the 'Spacing' inspector pane, where when the pane is hidden the user can still change the line spacing at a lower granularity.
- Show and hide panes
- Configurable from interface builder as inspectables
- Optional supply a view as a header view, and set its visibility (always show, show when collapsed)
- Optional automatic scroll view support
- Optional animation
- Optional separators or bounding boxes
- Optional drag/drop reordering of panes
- Show or hide individual panes without removing them
- Expand or contract individual panes
Copy the swift files from the
DSFInspectorPanes subfolder to your project
Add the following to your
pod 'DSFInspectorPanes', :git => 'https://github.com/dagronf/DSFInspectorPanes'
- Create an instance of
DSFInspectorPanesViewand add it to a view, or
- Use Interface Builder to add a custom view, and change the class to
animated: Animate the expanding/hiding of the panes
embeddedInScrollView: Embed the panes view in a scroll view
showSeparators: Insert a separator between each pane (optional)
showBoxes: Show a box around each inspector pane (optional)
titleFont: Specify a custom font to use for the title for the panes
spacing: Set the vertical spacing between each pane
canDragRearrange: Allow the user to change the ordering of the panes via drag/drop or touchbar
Add an inspector pane
Add a new inspector pane to the container
var propertyPanes = DSFInspectorPanesView(frame: .zero, animated: true, embeddedInScrollView: false, titleFont: NSFont.systemFont(ofSize: 13)) var inspectorView = NSView() // <--- your inspector pane view var inspectorHeaderView = NSView() // <--- your inspector pane header view propertyPanes.addPane( title: "My inspector Pane", view: inspectorView, headerAccessoryView: inspectorHeaderView, expansionType: .expanded) }
Expand an existing pane
var propertyPanes = DSFInspectorPanesView() … propertyPanes.panes.expanded = true propertyPanes.panes.expanded = false
Show or hide a pane
var propertyPanes = DSFInspectorPanesView() … propertyPanes.panes.hide = true propertyPanes.panes.hide = false
Reordering and moving
Move the property pane at index 0 to index 4
propertyPanes.move(index: 0, to: 4)
Swap property panes at index 0 and index 4
propertyPanes.swap(index: 0, with: 4)
Remove the pane at index 1
Remove all panes
RSVerticallyCenteredTextFieldCell - Red Sweater Software
DraggableStackView - Mark Onyschuk
Interface Builder integration
Showing the ability to display a secondary UI element for when the pane is contracted
- Updates for latest Xcode and dependent libraries
- Added a 'always show header accessory' option. Default behaviour has not been changed.
- Added an objective-c demo
MIT License Copyright (c) 2020 Darren Ford Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.