Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. - (void) scaleFrom: (float) s_old
  2.                 to: (float) s_new
  3.               time: (float) t
  4. {
  5.     CABasicAnimation * scaleAnimation = [CABasicAnimation animationWithKeyPath: @"transform.scale"];
  6.    
  7.     [scaleAnimation setDuration:  t ];
  8.     [scaleAnimation setFromValue:  (id) [NSNumber numberWithDouble: s_old] ];
  9.     [scaleAnimation setToValue:  (id) [NSNumber numberWithDouble: s_new] ];
  10.     [scaleAnimation setTimingFunction:  [CAMediaTimingFunction functionWithName: kCAMediaTimingFunctionEaseOut] ];
  11.     [scaleAnimation setFillMode: kCAFillModeForwards];
  12.     scaleAnimation.removedOnCompletion = NO;
  13.    
  14.     [self.contentsLayer addAnimation: scaleAnimation
  15.                               forKey: @"transform.scale"];
  16.    
  17.     if (self.displayShadow && self.shadowLayer)
  18.         [self.shadowLayer addAnimation: scaleAnimation
  19.                                 forKey: @"transform.scale"];   
  20.  
  21.     size = s_new;
  22. }
  23.  
  24. // - - -
  25.  
  26. - (void) resize: (float) newSize
  27. {
  28.     [self scaleFrom: size
  29.                  to: newSize
  30.                time: 1.];
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement