我正在尝试使用动画显示视图,但我得到的只是
> NSViewAnimation target is not view or window ((null))
这很奇怪,因为我很确定我添加的目标是一个视图。我尝试从superview的VC运行动画:
if let popoverVC = storyboard?.instantiateController(withIdentifier: NSStoryboard.SceneIdentifier(rawValue: "NewEventPopoverViewController")) as? NewEventPopoverViewController {
self.popoverVC = popoverVC
let myView = popoverVC.view
self.view.addSubview(myView)
let animation = NSViewAnimation.init(viewAnimations: [[.target: myView], [.startFrame: myView.frame.insetBy(dx: 20, dy: 20)], [.endFrame: myView.frame], [.effect: NSViewAnimation.EffectName.fadeIn]])
animation.duration = TimeInterval(1)
animation.start()
}
因为那不起作用,我也尝试从视图的VC本身运行动画:
override func viewDidLoad() {
super.viewDidLoad()
let animation = NSViewAnimation.init(viewAnimations: [[.target: self.view], [.startFrame: self.view.frame.insetBy(dx: 20, dy: 20)], [.endFrame: self.view.frame], [.effect: NSViewAnimation.EffectName.fadeIn]])
animation.duration = TimeInterval(1)
animation.start()
}
但我只是再次收到相同的错误消息。