Swiftpack.co - ChimeHQ/WindowTreatment as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by ChimeHQ.
ChimeHQ/WindowTreatment 2.1.1
Tools for happier work with NSWindow
⭐️ 45
🕓 2 weeks ago
.package(url: "https://github.com/ChimeHQ/WindowTreatment.git", from: "2.1.1")

Build Status License Platforms


WindowTreatment is a small set of classes and extensions to aid in working with NSWindow and its associated functions.


Swift Package Manager:

dependencies: [
    .package(url: "https://github.com/ChimeHQ/WindowTreatment")



A simple container view that makes it much easier to correctly position content under the titlebar of a host NSWindow. This turns out to be a fairly esoteric thing to do, but can be essential when your NSWindow has a transparent titlebar.

let titlebarAwareView = WindowTitlebarAwareView()

// myView will always be correctly position below the containing window's
// titlebar region, and react accordingly if the titlebar size/state changes

titlebarAwareView.contentView = myView
// ...


A wrapper controller useful in cases where you need to use WindowTitlebarAwareView with a system that only accepts NSViewControllers, like NSSplitViewController.


Wrappers around observation of NSWindow states for key, main, and tabbing. Very useful for UI updates in response to these changes. Particularly for tab state, which is very challenging to observe correctly in all cases.


Super-simple class that uses WindowStateObserver and provides a nice base for NSView subclasses that need to change their appearance depending on host window main/key state.


A class that tracks changes in the application's windows, simplifying logic that depends on the state of all windows.

NSWindow Extensions

Sizing conveniences:

// simple method to size a window to pleasing dimensions relative to its screen


Title bar transparency helpers:

// This method also handles the height adjustments needed when removing transparency
window.titlebarTransparentWithFullSizeContent = true

window.usesFullSizeContentView = true

NSView Extensions

Window state:


Suggestions or Feedback

We'd love to hear from you! Get in touch via twitter, an issue, or a pull request.

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.


Stars: 45
Last commit: 2 weeks ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Release Notes

2 weeks ago
  • warn about observing windows that cannot become key/main

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics