0
我想製作正確的幻燈片,像Siri窗口。因此,用戶點擊按鈕後,我做的:nswindow animator不能在窗口控制器工作
self.myWindowController.showWindow(nil)
在窗口控制:
override func windowDidLoad() {
super.windowDidLoad()
if let window = window, let screen = window.screen {
window.makeKeyAndOrderFront(nil)
window.animationBehavior = .none
let offsetFromLeftOfScreen: CGFloat = 30
let offsetFromTopOfScreen: CGFloat = 30
let screenRect = screen.visibleFrame
let newOriginX = screenRect.maxX - window.frame.width - offsetFromLeftOfScreen
let newOriginY = screenRect.maxY - window.frame.height - offsetFromTopOfScreen
DispatchQueue.main.asyncAfter(deadline: .now()+1.0) {
NSAnimationContext.beginGrouping()
NSAnimationContext.current().duration = 3.0
window.animator().setFrameOrigin(NSPoint(x: newOriginX, y: newOriginY))
NSAnimationContext.endGrouping()
}
window.titleVisibility = .hidden
}
但窗口移動後延遲1秒到右上位置沒有動畫。爲什麼?