AppDelegate.swift 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. //
  2. // AppDelegate.swift
  3. // ACarouselDemo macOS
  4. //
  5. // Created by 帝云科技 on 2020/11/17.
  6. //
  7. import Cocoa
  8. import SwiftUI
  9. @NSApplicationMain
  10. class AppDelegate: NSObject, NSApplicationDelegate {
  11. var window: NSWindow!
  12. func applicationDidFinishLaunching(_ aNotification: Notification) {
  13. // Create the SwiftUI view that provides the window contents.
  14. let contentView = ContentView()
  15. // Create the window and set the content view.
  16. window = NSWindow(
  17. contentRect: NSRect(x: 0, y: 0, width: 480, height: 300),
  18. styleMask: [.titled, .closable, .miniaturizable, .resizable, .fullSizeContentView],
  19. backing: .buffered, defer: false)
  20. window.isReleasedWhenClosed = false
  21. window.center()
  22. window.setFrameAutosaveName("Main Window")
  23. window.contentView = NSHostingView(rootView: contentView)
  24. window.makeKeyAndOrderFront(nil)
  25. }
  26. func applicationWillTerminate(_ aNotification: Notification) {
  27. // Insert code here to tear down your application
  28. }
  29. }