[英]How to set a NSView hidden with FadeOut animation in cocoa?
I'm hiding a subview from a CustomView element with the following code:我使用以下代码从 CustomView 元素隐藏子视图:
[[[theViewcont subviews] objectAtIndex:0] setHidden:TRUE]
how can I add a fade animation when hiding this NSView?隐藏此 NSView 时如何添加淡入淡出动画?
Found the solution HERE CocoaDev:CoreAnimation在这里找到解决方案 CocoaDev:CoreAnimation
so when you have something like this to hide your subview:所以当你有这样的东西来隐藏你的子视图时:
[[[theViewcont subviews] objectAtIndex:0] setAlphaValue:0.0];
to animate that action you just should so the following addition:要为该动作设置动画,您只需添加以下内容:
[[[[theViewcont subviews] objectAtIndex:0] animator] setAlphaValue:0.0];
so there you have the right way to 'fade out' a subview in Cocoa.所以你有正确的方法来“淡出”可可中的子视图。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.