Skip to content

Instantly share code, notes, and snippets.

@khcrysalis
Created January 23, 2025 21:33
Show Gist options
  • Save khcrysalis/60a6076fe7d747921b0d9e2ee4145157 to your computer and use it in GitHub Desktop.
Save khcrysalis/60a6076fe7d747921b0d9e2ee4145157 to your computer and use it in GitHub Desktop.
Apple-style onboarding for applications
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