请参阅代码片段。尝试使用 NSViewAnimation 淡入其主窗口。NIB 只有一个窗口/菜单(例如,这个项目几乎直接来自可可应用程序向导)。通过取消选中“启动时可见”,已在 NIB 中修改了该窗口。委托方法 animationShouldStart 永远不会被调用。如果这很重要,我在 xcode 4.2 中使用 10.7。
我基本上只是不明白为什么这不起作用。请给我一些理智。
谢谢
#import "TestAppDelegate.h"
@implementation TestAppDelegate
@synthesize window = _window;
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
// Insert code here to initialize your application
// [[self window] orderFront: self];
NSRect _saveRect = [_window frame];
NSRect _zeroRect = _saveRect;
_zeroRect.size = NSMakeSize(0, 0);
NSDictionary *fadeInAttrs = [NSDictionary dictionaryWithObjectsAndKeys:
[_window contentView], NSViewAnimationTargetKey,
NSViewAnimationFadeInEffect, NSViewAnimationEffectKey,
[NSValue valueWithRect:_zeroRect], NSViewAnimationStartFrameKey,
[NSValue valueWithRect:_saveRect], NSViewAnimationEndFrameKey,
nil];
NSViewAnimation *_viewAnimIn = [[NSViewAnimation alloc] initWithViewAnimations:[NSArray arrayWithObjects: fadeInAttrs, nil]];
[_viewAnimIn setDuration:1.0];
[_viewAnimIn setAnimationCurve:NSAnimationEaseInOut];
[_viewAnimIn setAnimationBlockingMode:NSAnimationBlocking];
[_viewAnimIn setDelegate:self];
[_viewAnimIn startAnimation];
}
- (BOOL)animation:(NSAnimation *)animation animationShouldStart:(NSAnimation*) _anim
{
NSLog(@"%@ shouldStart", _anim);
return YES;
}
@end