Breaking News
Home / iOS / iOS Snippets / How to create a Pulse Effect on UIViews using Core Animation in iOS?

How to create a Pulse Effect on UIViews using Core Animation in iOS?

Core Animation based on Quartz provides very simple ways to create special effects in your game or application.

The following shows how to create a Pulse Effect of any UIView (e.g. UIButtonView, UIImageView etc.)

  1. +(void)pulse:(UIView*)view toSize: (float) value withDuration:(float) duration
  2. {
  3.     CABasicAnimation *pulseAnimation = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
  4.     pulseAnimation.duration = duration;
  5.     pulseAnimation.toValue = [NSNumber numberWithFloat:value];;
  6.     pulseAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
  7.     pulseAnimation.autoreverses = YES;
  8.     pulseAnimation.repeatCount = FLT_MAX;
  9.    
  10.     [view.layer addAnimation:pulseAnimation forKey:nil];
  11. }
[pb_builder]

Check Also

EKCalendar – That account does not allow calendars to be added or removed

Usecase When I am trying to create a new Calendar programmatically using the EventKit API …

Advertisment ad adsense adlogger