Core Animation Color Transitions

Discussion in 'Mac Programming' started by Darkroom, Oct 16, 2008.

  1. Darkroom Guest

    Darkroom

    Joined:
    Dec 15, 2006
    Location:
    Montréal, Canada
    #1
    i have a view with "Wants Core Animation Layer" checked in IB, and i'm trying to animate between the colors set by the IBActions:

    Code:
    - (IBAction)backgroundBlack:(id)sender
    	{
    	[[self animator] setBackgroundColors:[NSArray arrayWithObjects:[NSColor blackColor], nil]];
    	}
    
    - (IBAction)backgroundWhite:(id)sender
    	{
    	[[self animator] setBackgroundColors:[NSArray arrayWithObjects:[NSColor whiteColor], nil]];
    	}
    
    the view switches colors, but it doesn't animate (EX: Preview > Preferences > General > Window Background)

    coding [self animator] setFrame: is the way i make my window resize with CA, so is this not the same with [self animator] setBackgroundColors:?
     
  2. kpua macrumors 6502

    Joined:
    Jul 25, 2006
    #2
    The animator proxy is only able to create implicit animations for a few properties like frame size/origin, opacity, rotation, and so on.

    "backgroundColors" is a special property of NSCollectionView and therefore not animatable by the animator by default. Don't quote me on this, but you might be able to set up a custom property animation for this... I know there is support for custom property animations, but I'm not sure where to begin implementing it.

    Also, just because Preview animates its background color, that doesn't mean they use -animator to do it, or even use Cocoa at all. They're probably modifying the layer's property directly.
     
  3. Darkroom thread starter Guest

    Darkroom

    Joined:
    Dec 15, 2006
    Location:
    Montréal, Canada
    #3
    humm... i suppose setting this up with an NSTimer would be more ideal with my skill set... but i can't even see that being possible
     

Share This Page