这是我的代码:
- (IBAction)showTaskDetailView:(id)sender {
[window setContentView:viewTaskView];
}
我将如何淡出当前视图并淡入详细视图?
这是我的代码:
- (IBAction)showTaskDetailView:(id)sender {
[window setContentView:viewTaskView];
}
我将如何淡出当前视图并淡入详细视图?
此处的示例代码(稍作调整):
- (void)crossFadeWithOld:(NSView *)oldView andNew:(NSView *)newView
{
[window setContentView:newView];
NSDictionary *oldFadeOut = nil;
if (oldView != nil) {
oldFadeOut = [NSDictionary dictionaryWithObjectsAndKeys:
oldView, NSViewAnimationTargetKey,
NSViewAnimationFadeOutEffect,
NSViewAnimationEffectKey, nil];
}
NSDictionary *newFadeIn;
newFadeIn = [NSDictionary dictionaryWithObjectsAndKeys:
newView, NSViewAnimationTargetKey,
NSViewAnimationFadeInEffect,
NSViewAnimationEffectKey, nil];
NSArray *animations;
animations = [NSArray arrayWithObjects:
newFadeIn, oldFadeOut, nil];
NSViewAnimation *animation;
animation = [[NSViewAnimation alloc]
initWithViewAnimations: animations];
[animation setAnimationBlockingMode: NSAnimationBlocking];
[animation setDuration: 0.5]; // or however long you want it for
[animation startAnimation]; // because it's blocking, once it returns, we're done
[animation release];
}
不要改变内容视图;将两个视图放在同一个内容视图中,并使用NSViewAnimation淡出另一个视图。