A Cocoa, auto-layout managed view to build and manage inspector panes equivalent to the inspectors in Apple’s Pages and Numbers applications.
Why?
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.
Expanded
Contracted
Features
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
Installation
Direct
Copy the swift files from the DSFInspectorPanes subfolder to your project
CocoaPods
Add the following to your Podfiles file
pod 'DSFInspectorPanes', :git => 'https://github.com/dagronf/DSFInspectorPanes'
API
Create
Create an instance of DSFInspectorPanesView and add it to a view, or
Use Interface Builder to add a custom view, and change the class to DSFInspectorPanesView
Properties
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
Methods
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)
}
Showing the ability to display a secondary UI element for when the pane is contracted
Releases
1.3.0:
Updates for latest Xcode and dependent libraries
1.2.0:
Added a ‘always show header accessory’ option. Default behaviour has not been changed.
Added an objective-c demo
License
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.
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.
Why?
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.
Features
Installation
Direct
Copy the swift files from the
DSFInspectorPanes
subfolder to your projectCocoaPods
Add the following to your
Podfiles
fileAPI
Create
DSFInspectorPanesView
and add it to a view, orDSFInspectorPanesView
Properties
animated
: Animate the expanding/hiding of the panesembeddedInScrollView
: Embed the panes view in a scroll viewshowSeparators
: 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 panesspacing
: Set the vertical spacing between each panecanDragRearrange
: Allow the user to change the ordering of the panes via drag/drop or touchbarMethods
Add an inspector pane
Add a new inspector pane to the container
Expand an existing pane
Show or hide a pane
Reordering and moving
Move the property pane at index 0 to index 4
Swap property panes at index 0 and index 4
Removing
Remove the pane at index 1
Remove all panes
Thanks
RSVerticallyCenteredTextFieldCell - Red Sweater Software
DraggableStackView - Mark Onyschuk
Screenshots
(Movie) Drag Drop Reordering
Interface Builder integration
Pane modes
Showing the ability to display a secondary UI element for when the pane is contracted
Releases
1.3.0:
1.2.0:
License