Skip navigation.
 
mlCATransactions not working
FROM : Adam Radestock
DATE : Sun May 18 18:00:36 2008

Hi everyone,

I've been struggling to work out how to animate some properties on my 
NSButton subclass. I have looked through all the examples given in 
Apple's docs, but can't work out why my code doesn't animate.

My code is:
   [CATransaction begin]; // Begin grouping animated property changes
   
   if (highlightEffect == SGUIButtonOpaqueEffect) {
       
       [CATransaction begin];
       [CATransaction setValue:[NSNumber numberWithFloat:5.0f]
                        forKey:kCATransactionAnimationDuration];
       self.layer.opacity = 1.0;
       [CATransaction commit];
       
   } else if (highlightEffect == SGUIButtonSlideEffect) {
       
       [CATransaction begin];
       [CATransaction setValue:[NSNumber numberWithFloat:1.0f]
                        forKey:kCATransactionAnimationDuration];
       self.layer.bounds = CGRectMake(self.layer.position.x, 
self.layer.position.y, self.bounds.size.width + 10, 
self.bounds.size.height);
       [CATransaction commit];
       
       [CATransaction begin];
       [CATransaction setValue:[NSNumber numberWithFloat:2.0f]
                        forKey:kCATransactionAnimationDuration];
       self.layer.position = CGPointMake(self.layer.position.x - 
self.layer.bounds.size.width, self.layer.position.y);
       [CATransaction commit];
       
   }
   
   [CATransaction commit];

Can anyone see any problems with this? Why aren't there any animations 
when this code executes?

Any help greatly appreciated.

Adam Radestock
Glass Monkey Software

Related mailsAuthorDate
mlCATransactions not working Adam Radestock May 18, 18:00
mlRe: CATransactions not working Brian Christensen May 18, 21:23
mlRe: CATransactions not working Adam Radestock May 19, 19:06
mlRe: CATransactions not working Brian Christensen May 19, 19:23
mlRe: CATransactions not working Adam Radestock May 19, 20:03
mlRe: CATransactions not working Paul Bailey May 19, 20:09
mlRe: CATransactions not working Adam Radestock May 19, 20:17
ml[MODERATOR] Re: CATransactions not working Scott Anguish May 20, 19:00