Domanda

Ecco il mio codice:

- (IBAction)showTaskDetailView:(id)sender {
    [window setContentView:viewTaskView];
}

Come faccio a sfumare la vista corrente e dissolvenza nella visualizzazione dettagliata?

È stato utile?

Soluzione

Non modificare la visualizzazione dei contenuti; mettere entrambe le viste nella stessa vista contenuti e utilizzare NSViewAnimation a svanire uno fuori e l'altro in.

Altri suggerimenti

Esempio di codice qui (ottimizzato un po '):

- (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];    

}
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top