我有一台运行 OSX 10.8 的笔记本电脑,这是我用来开发应用程序的。我今天去我的桌面上测试了这个应用程序——它运行 10.9——发现除了一个动画之外一切都一样。
我有一个介绍屏幕,希望它在下一个屏幕中淡出并淡出;但是,淡入的第二个屏幕上有一个 NSTableView。在 10.8 中,表格视图随着它所在的视图的其余部分正确淡入,但在 10.9 中,当动画被触发时,表格视图完全立即出现,而不是与视图的其余部分一起动画。
我创建了一个小示例,并附上了它在下面运行的视频以及代码。在示例中,视图应该从纯蓝色视图淡化为具有 NSTableView 和红色背景的视图。为了简单起见,我只是在应用程序启动时启动动画,这就是为什么在 Mavericks 运行开始时表格视图是完全可见的。
AppDelegate.m:
#import "AppDelegate.h"
#import "SecondViewController.h"
#import "BlueBGView.h"
@implementation AppDelegate
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
BlueBGView *blueView = [[BlueBGView alloc]initWithFrame:self.window.frame];
SecondViewController *SVC = [[SecondViewController alloc]initWithNibName:@"SecondViewController" bundle:nil];
[self.window.contentView addSubview: blueView];
blueView.frame = ((NSView*) self.window.contentView).bounds;
[self.window.contentView addSubview: SVC.view];
//Animate
NSMutableDictionary *blueViewDict, *SVCDict;
blueViewDict = [NSMutableDictionary dictionaryWithCapacity:2];
[blueViewDict setObject:blueView forKey:NSViewAnimationTargetKey];
[blueViewDict setObject:NSViewAnimationFadeOutEffect
forKey:NSViewAnimationEffectKey];
SVCDict = [NSMutableDictionary dictionaryWithCapacity:2];
[SVCDict setObject:SVC.view forKey:NSViewAnimationTargetKey];
[SVCDict setObject:NSViewAnimationFadeInEffect forKey:NSViewAnimationEffectKey];
NSViewAnimation *animation = [[NSViewAnimation alloc]initWithViewAnimations:[NSArray arrayWithObjects:blueViewDict, SVCDict, nil]];
[animation setDuration: 5];
[animation setAnimationCurve:NSAnimationEaseIn];
[animation startAnimation];
}
@end