miho
miho

Reputation: 12085

Push view animation on OS X

I am trying to add a push animation while displaying different views in a kind of image slider. Slides are displayed as expected, but there isn't any animation. I am using the following lines of code to create the animation. (self is a subclass of NSView)

[NSAnimationContext beginGrouping];

CATransition *transition = [CATransition animation];
[transition setDuration:0.33f];
[transition setType:kCATransitionPush];
[transition setSubtype:kCATransitionFromLeft];
[transition setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut]];
[self setAnimations:[NSDictionary dictionaryWithObject:transition forKey:@"subviews"]];

[[self animator] replaceSubview:self.displayedSlide with:slideToDisplay];

[NSAnimationContext endGrouping];

Any idea of what I've done wrong?

Upvotes: 0

Views: 501

Answers (1)

miho
miho

Reputation: 12085

I've had to add [self setWantsLayer:YES]; and now it works.

Upvotes: 1

Related Questions