这很简单,所以我无论如何也找不到哪里出了问题,我翻阅了文档作为指南,但它仍然不起作用。我在一个更大的视图中有一个视图。IBAction
应该淡出内部视图...就这样。下面是我得到的信息:
NSViewAnimation *theAnim;
NSMutableDictionary *viewDict;
// Create the attributes dictionary for the view.
viewDict = [NSMutableDictionary dictionaryWithCapacity:2];
// Set the target object to be the view.
[viewDict setObject:_innerView forKey:NSViewAnimationTargetKey];
// Set this view to fade out
[viewDict setObject:NSViewAnimationFadeOutEffect forKey:NSViewAnimationEffectKey];
theAnim = [[NSViewAnimation alloc] initWithViewAnimations:@[viewDict]];
// Set some additional attributes for the animation.
[theAnim setDuration:1.0];
// Run the animation.
[theAnim startAnimation];
我用NSLog
检查了viewDict
和theAnim
,nil
也没有。我很可能是从一个老程序中复制出来的,现在找不到哪里出了问题。
我使用的是Xcode 5.1.1。
发布于 2014-08-23 11:27:20
现代的方法要简单得多:
[NSAnimationContext runAnimationGroup:^(NSAnimationContext *context) {
context.duration = 1;
view.animator.alphaValue = 0;
}
completionHandler:^{
view.hidden = YES;
view.alphaValue = 1;
}];
如果视图层次结构是分层的,那么这样做就足够了:
view.animator.hidden = YES;
https://stackoverflow.com/questions/25456080
复制相似问题