Last active
July 14, 2025 02:37
-
-
Save khcrysalis/60a6076fe7d747921b0d9e2ee4145157 to your computer and use it in GitHub Desktop.
Apple-style Onboarding Window Setup for macOS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func showOnboarding() { | |
let window = NSWindow( | |
contentRect: NSRect(x: 0, y: 0, width: 640, height: 600), | |
styleMask: [.fullSizeContentView, .nonactivatingPanel], | |
backing: .buffered, | |
defer: false | |
) | |
// Replace your own view here | |
let onboardingWindow = NSHostingView(rootView: EmptyView()) | |
if let screen = NSScreen.main { | |
window.setFrameOrigin(NSPoint( | |
x: (screen.frame.width - window.frame.width) / 2, | |
y: (screen.frame.height - window.frame.height) / 2 | |
)) | |
} | |
window.animationBehavior = .documentWindow | |
window.backgroundColor = .clear | |
window.isReleasedWhenClosed = true | |
window.level = .floating | |
window.contentView = onboardingWindow | |
window.makeKeyAndOrderFront(true) | |
onboardingWindow.wantsLayer = true | |
onboardingWindow.layer!.cornerRadius = 10 | |
window.invalidateShadow() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment