Layer-backed NSView animation

做~自己de王妃 提交于 2019-12-07 08:57:04

问题


I have a certain NSView that I want to animate, but that NSView has a NSTableView inside which does not display correclty when the view is layer-backed (which in turn is nececessary to animate a view). So my answer was to make the view layer-backed right before animating, and then when the animation was done remove the layer, like this:

[animatingView setWantsLayer: YES];

[NSAnimationContext beginGrouping];

[[animatingView animator] animateSomething];

[[NSAnimationContext currentContext] setCompletionHandler: ^{
    [animatingView setWantsLayer: NO];
}];

[NSAnimationContext endGrouping];

However, with this code the view doesn't animate at all. I found that if I remove the [animatingView setWantsLayer: NO]; line it animates just right, but then the table view doesn't display correctly (see this question for an example of one of the problems).

So, my question is: how do I solve this? I want to animate a view, but I want tables to display properly, and this workaround doesn't work. And I don't get why...


回答1:


Once you make NSView layer-backed it cannot be reverted.

I suggest you to try to make your NSTableView a sibling of the layer-backed view, not a child.



来源:https://stackoverflow.com/questions/15591676/layer-backed-nsview-animation

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