Swiftpack.co - Package - ChimeHQ/WindowTreatment

Github CI Carthage compatible


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



You can use Carthage to intall this as a static library. However, because the library relies on Objective-C categories to extend AppKit classes, you must include "-ObjC" in your OTHER_LDFLAGS setting.

github "ChimeHQ/WindowTreatment"

Swift Package Manager:

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



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 fair 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.


Convenience wrappers around observation of NSWindow states like key and main. Very useful for UI changes in response to these changes.


Super-simple class that uses WindowStateObserver and provides a nice base for NSView subclasses that need to change their appearance depending on host window 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:

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: 26


Used By

Total: 0


v.1.2.4 - 2020-04-23 17:05:51

Tidying code after SwiftLint run

v1.2.3 - 2019-11-08 21:40:38

  • windowIsOnActiveSpace
  • ApplicationWindowState

v1.2.1 - 2019-08-28 00:34:50

Includes some expanded documentation.

v1.2 - 2019-05-30 13:24:18

  • SwiftPM support
  • Some improvements to WindowStateAwareView

v1.1 - 2019-05-29 20:58:43

Now includes two new classes for NSWindow state observation. Very handy for NSView subclasses that need to change their UI/behavior depending on host window state.

v1.0 - 2019-05-10 21:34:01

Initial Release!