层支持NSView动画 [英] Layer-backed NSView animation

查看:435
本文介绍了层支持NSView动画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个NSView,我想动画,但NSView有一个NSTableView里面,当视图是layer-backed(这反过来是接近的动画视图)时不显示相关性。所以我的答案是使动画之前的视图层支持,然后当动画完成删除层,像这样:

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];

但是,使用此代码,视图不会生成动画。我发现如果我删除 [animatingView setWantsLayer:NO]; 行动画只是正确,但然后表视图不正确显示(参见问题的问题之一的示例)。

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...

推荐答案

一旦你使用NSView图层支持,就无法恢复。

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

我建议你尝试让你的NSTableView是一个兄弟的层支持视图,而不是一个孩子。

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

这篇关于层支持NSView动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆