NSPoover 自定义动画
有没有办法为 NSPopover 创建自定义动画?
我可以使用 animates
属性关闭动画,但是由于 NSPopover 是 NSResponder
的子类,而不是正确的视图或窗口,我无法弄清楚如何设置动画我自己。
Is there any way to create a custom animation for NSPopover?
I can switch off the animation by using the animates
property, however since NSPopover is a subclass of NSResponder
and not a proper view or window I can't figure out how to animate it myself.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
NSPopover 有一个名为
_popoverWindow
的私有属性,类型为_NSPopoverWindow
。_NSPopoverWindow
有setAnimates:
方法。您可以使用此方法禁用默认动画,并使用NSPopoverDelegate
制作_popoverWindow
的自定义动画。NSPopover has a private property named
_popoverWindow
, type of_NSPopoverWindow
._NSPopoverWindow
hassetAnimates:
method. You can disable default animation using this method, and make a custom animation of_popoverWindow
usingNSPopoverDelegate
.弹出窗口将根据其显示的视图进行动画处理。通过以特定方式调整视图大小,将使弹出窗口在调整视图大小时具有动画效果。当然,只有当您想要的动画相当简单并且可以实现到弹出窗口的视图时,这才有效。
The popover will animate depending on the view it is displaying. By just resizing the view in a particular way will make the popover animate while it's resizing the view. Of course, this will only work if the animation you want is fairly simple and can be implemented to the popover's view.
无法连接到
NSPopover
的动画系统。我对接口进行了类转储,它甚至看起来没有任何有用的私有方法。如果您想要一个自定义的动画弹出窗口,您将需要从头开始实现它(这实际上并不难)。
There is no way to hook into the animation system of
NSPopover
. I did a class-dump of the interface and it doesn't even look like there are any useful private methods.If you want a custom animated popover you will need to implement it from scratch (which is not that hard, really).