Core Animation - Sheet-like Window Sliding

孤人 提交于 2020-01-01 18:12:42

问题


How difficult would it be to use core animation to make an NSView slide in an out of view like a sheet? Generally speaking, what would be involved in accomplishing this? I've been reading through the CA documentation, but it's been hard for me to pinpoint which parts are relevant to what I want to do since I have no experience with the framework.

Any tips at all would be much appreciated.

Thanks.


回答1:


Since you're talking of a NSView, you're probably using Cocoa's animation support, not CA directly. In this case, you just need to set the view's frame through the view's animator object:

[theView setFrame:offscreenFrame];
[[theView animator] setFrame:finalFrame];

Unfortunately, Cocoa view animation interacts badly with the more advanced features of CA, like setting an easing. You might have more luck using NSViewAnimation instead, which is not Core Animation-backed and allows for a little more flexibility.



来源:https://stackoverflow.com/questions/574680/core-animation-sheet-like-window-sliding

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!