在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):lukakerr/NSWindowStyles开源软件地址(OpenSource Url):https://github.com/lukakerr/NSWindowStyles开源编程语言(OpenSource Language):Swift 100.0%开源软件介绍(OpenSource Introduction):Swift NSWindow Style ShowcaseA 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 All code is in If you have a style to add, please make a pull request. 1. Hide titleDon't show the title text in the titlebar. window?.titleVisibility = .hidden 2. Hide titlebarHide the titlebar completely. window?.styleMask.remove(.titled) 3. Vibrant backgroundCreate a vibrant background where whatever is behind the window can be slightly seen. This uses let visualEffect = NSVisualEffectView()
visualEffect.blendingMode = .behindWindow
visualEffect.state = .active
visualEffect.material = .dark
window?.contentView = visualEffect
4. Vibrant background with transparent titlebarSame 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 titlebarSame 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 custom border radius and no titlebarA vibrant window with a custom border radius. The border radius value can be changed at 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. Vibrant background with transparent titlebar and no window controlsA vibrant window with a standard border radius and no window controls or title. let visualEffect = NSVisualEffectView()
visualEffect.blendingMode = .behindWindow
visualEffect.state = .active
visualEffect.material = .dark
window?.contentView = visualEffect
window?.styleMask.insert(.titled)
window?.titlebarAppearsTransparent = true
window?.titleVisibility = .hidden
window?.standardWindowButton(.miniaturizeButton)?.isHidden = true
window?.standardWindowButton(.closeButton)?.isHidden = true
window?.standardWindowButton(.zoomButton)?.isHidden = true
window?.isMovableByWindowBackground = true 8. Transparent titlebarA window with a transparent titlebar. window?.titlebarAppearsTransparent = true 9. Transparent titlebar with background colorSame as above with a background color. window?.titlebarAppearsTransparent = true
window?.backgroundColor = .red 10. ToolbarA window with a toolbar. let customToolbar = NSToolbar()
window?.titleVisibility = .hidden
window?.toolbar = customToolbar 11. Transparent toolbarSame as above, with the toolbar transparent. let customToolbar = NSToolbar()
window?.titlebarAppearsTransparent = true
window?.titleVisibility = .hidden
window?.toolbar = customToolbar 12. Transparent toolbar without seperatorSame as above, without the toolbar seperator. let customToolbar = NSToolbar()
customToolbar.showsBaselineSeparator = false
window?.titlebarAppearsTransparent = true
window?.titleVisibility = .hidden
window?.toolbar = customToolbar 13. Transparent toolbar with background color and without seperatorSame as above, with a background color. let customToolbar = NSToolbar()
customToolbar.showsBaselineSeparator = false
window?.titlebarAppearsTransparent = true
window?.titleVisibility = .hidden
window?.backgroundColor = .red
window?.toolbar = customToolbar 14. Translucent toolbarA 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 15. Translucent titlebarSame 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")) 16. Transparent titlebar without titleSame 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")) 17. macOS Mojave dark modeThe macOS Mojave dark mode appearance. if #available(OSX 10.14, *) {
window?.appearance = NSAppearance(named: .darkAqua)
} |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论