All Projects → lukakerr → Nswindowstyles

lukakerr / Nswindowstyles

Licence: apache-2.0
A showcase of the many different styles of windows possible with NSWindow on macOS

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Nswindowstyles

Sbplayerclient
支持全格式的mac版视频播放器
Stars: ✭ 110 (-86.27%)
Mutual labels:  osx, cocoa
Cocoa Rest Client
A free, native Apple macOS app for testing HTTP/REST endpoints
Stars: ✭ 2,257 (+181.77%)
Mutual labels:  osx, cocoa
Macassistant
Google Assistant for macOS!
Stars: ✭ 1,564 (+95.26%)
Mutual labels:  osx, cocoa
Macqq
mac版QQ,swift,macOS,仿QQ mac端
Stars: ✭ 72 (-91.01%)
Mutual labels:  osx, cocoa
Stprivilegedtask
An NSTask-like wrapper around the macOS Security Framework's AEWP function to run shell commands with root privileges in Objective-C / Cocoa.
Stars: ✭ 335 (-58.18%)
Mutual labels:  osx, cocoa
Dogetv macos
🎬 dogeTV for macOS
Stars: ✭ 92 (-88.51%)
Mutual labels:  osx, cocoa
Usbdeviceswift
wrapper for IOKit.usb and IOKit.hid written on pure Swift that allows you convenient work with USB devices
Stars: ✭ 156 (-80.52%)
Mutual labels:  osx, cocoa
Subethaedit
General purpose plain text editor for macOS. Widely known for its live collaboration feature.
Stars: ✭ 1,183 (+47.69%)
Mutual labels:  osx, cocoa
Fab
🛍️ A Floating Action Button for macOS. Inspired by Material Design, and written in Swift.
Stars: ✭ 24 (-97%)
Mutual labels:  osx, cocoa
Criollo
A powerful Cocoa web framework and HTTP server for macOS, iOS and tvOS.
Stars: ✭ 229 (-71.41%)
Mutual labels:  osx, cocoa
Enlighten
💡 An integrated spotlight-based onboarding and help library for macOS, written in Swift.
Stars: ✭ 44 (-94.51%)
Mutual labels:  osx, cocoa
Xit
Mac OS X Git GUI
Stars: ✭ 700 (-12.61%)
Mutual labels:  osx, cocoa
Platypus
Create native Mac applications from command line scripts.
Stars: ✭ 1,893 (+136.33%)
Mutual labels:  osx, cocoa
Pywebview
Build GUI for your Python program with JavaScript, HTML, and CSS
Stars: ✭ 2,649 (+230.71%)
Mutual labels:  osx, cocoa
Strongbox
A KeePass/Password Safe Client for iOS and OS X
Stars: ✭ 586 (-26.84%)
Mutual labels:  osx, cocoa
Orsserialport
Serial port library for Objective-C and Swift macOS apps
Stars: ✭ 609 (-23.97%)
Mutual labels:  osx, cocoa
Design System Components
🛠 Component code and tests for the Australian Government design system
Stars: ✭ 696 (-13.11%)
Mutual labels:  design
Stylestage
A modern CSS showcase styled by community contributions. Add your stylesheet!
Stars: ✭ 724 (-9.61%)
Mutual labels:  design
Soundcast
Cast audio from macOS to Chromecast
Stars: ✭ 684 (-14.61%)
Mutual labels:  osx
Inbucket
Disposable webmail server (similar to Mailinator) with built in SMTP, POP3, RESTful servers; no DB required.
Stars: ✭ 685 (-14.48%)
Mutual labels:  osx

Swift NSWindow Style Showcase

Swift 5 Platform Github

A showcase of many of the different styles of windows possible with NSWindow on MacOS. In some examples, NSToolbar, and NSVisualEffectView are used. No private API's are used.

To test each style, clone the project, open it in Xcode, uncomment each block of code in WindowController.swift and run. The numbers above each block correspond to each style below.

All code is in WindowController.swift in the windowDidLoad function. You should just be able to place each block inside that function to get the exact same result.

If you have a style to add, please make a pull request.

1. Hide title

Don't show the title text in the titlebar.

window?.titleVisibility = .hidden

2. Hide titlebar

Hide the titlebar completely.

window?.styleMask.remove(.titled)

3. Vibrant background

Create a vibrant background where whatever is behind the window can be slightly seen. This uses NSVisualEffectView.

let visualEffect = NSVisualEffectView()
visualEffect.blendingMode = .behindWindow
visualEffect.state = .active
visualEffect.material = .dark
window?.contentView = visualEffect

visualEffect.material can take multiple values including:

  • .appearanceBased: based on the views appearance
  • .dark: dark appearance
  • .ultraDark: ultra dark appearance
  • .light: light appearance
  • .mediumLight: medium light appearance
  • others such as .menu, .popover, .selection, .sidebar and .titlebar

4. Vibrant background with transparent titlebar

Same as above, with a transparent titlebar.

let visualEffect = NSVisualEffectView()
visualEffect.blendingMode = .behindWindow
visualEffect.state = .active
visualEffect.material = .dark
window?.contentView = visualEffect

window?.titlebarAppearsTransparent = true
window?.styleMask.insert(.fullSizeContentView)

5. Vibrant background without titlebar

Same as above, without the titlebar.

let visualEffect = NSVisualEffectView()
visualEffect.blendingMode = .behindWindow
visualEffect.state = .active
visualEffect.material = .dark
window?.contentView = visualEffect

window?.styleMask.remove(.titled)
window?.isMovableByWindowBackground = true

6. Vibrant background with border radius and no titlebar

A vibrant window with a custom border radius. The border radius value can be changed at visualEffect.layer?.cornerRadius = 16.0.

let visualEffect = NSVisualEffectView()
visualEffect.translatesAutoresizingMaskIntoConstraints = false
visualEffect.material = .dark
visualEffect.state = .active
visualEffect.wantsLayer = true
visualEffect.layer?.cornerRadius = 16.0

window?.titleVisibility = .hidden
window?.styleMask.remove(.titled)
window?.backgroundColor = .clear
window?.isMovableByWindowBackground = true

window?.contentView?.addSubview(visualEffect)

guard let constraints = window?.contentView else {
  return
}

visualEffect.leadingAnchor.constraint(equalTo: constraints.leadingAnchor).isActive = true
visualEffect.trailingAnchor.constraint(equalTo: constraints.trailingAnchor).isActive = true
visualEffect.topAnchor.constraint(equalTo: constraints.topAnchor).isActive = true
visualEffect.bottomAnchor.constraint(equalTo: constraints.bottomAnchor).isActive = true

7. Transparent titlebar

A window with a transparent titlebar.

window?.titlebarAppearsTransparent = true

8. Transparent titlebar with background color

Same as above with a background color.

window?.titlebarAppearsTransparent = true
window?.backgroundColor = .red

9. Toolbar

A window with a toolbar.

let customToolbar = NSToolbar()
window?.titleVisibility = .hidden
window?.toolbar = customToolbar

10. Transparent toolbar

Same as above, with the toolbar transparent.

let customToolbar = NSToolbar()
window?.titlebarAppearsTransparent = true
window?.titleVisibility = .hidden
window?.toolbar = customToolbar

11. Transparent toolbar without seperator

Same as above, without the toolbar seperator.

let customToolbar = NSToolbar()
customToolbar.showsBaselineSeparator = false
window?.titlebarAppearsTransparent = true
window?.titleVisibility = .hidden
window?.toolbar = customToolbar

12. Transparent toolbar with background color and without seperator

Same as above, with a background color.

let customToolbar = NSToolbar()
customToolbar.showsBaselineSeparator = false
window?.titlebarAppearsTransparent = true
window?.titleVisibility = .hidden
window?.backgroundColor = .red
window?.toolbar = customToolbar

13. Translucent toolbar

A translucent toolbar allowing for content behind the toolbar to be slightly seen.

let customToolbar = NSToolbar()
window?.titleVisibility = .hidden
window?.styleMask.insert(.fullSizeContentView)
window?.contentView?.wantsLayer = true
window?.contentView?.layer?.contents = NSImage(named: NSImage.Name("Background"))
window?.toolbar = customToolbar

14. Translucent titlebar

Same as above with a titlebar instead of a toolbar.

window?.titleVisibility = .hidden
window?.styleMask.insert(.fullSizeContentView)
window?.contentView?.wantsLayer = true
window?.contentView?.layer?.contents = NSImage(named: NSImage.Name("Background"))

15. Transparent titlebar without title

Same as above with a transparent titlebar.

window?.titleVisibility = .hidden
window?.styleMask.insert(.fullSizeContentView)
window?.titlebarAppearsTransparent = true
window?.contentView?.wantsLayer = true
window?.contentView?.layer?.contents = NSImage(named: NSImage.Name("Background"))

16. macOS Mojave dark mode

The macOS Mojave dark mode appearance.

if #available(OSX 10.14, *) {
  window?.appearance = NSAppearance(named: .darkAqua)
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].