Skip to content

Instantly share code, notes, and snippets.

@sleimanzublidi
Created November 2, 2017 19:01
Show Gist options
  • Save sleimanzublidi/ccabe127ff68dca7365b90ca65a6624f to your computer and use it in GitHub Desktop.
Save sleimanzublidi/ccabe127ff68dca7365b90ca65a6624f to your computer and use it in GitHub Desktop.
Xamarin.iOS Pulse Animation
public static void Pulse(this UIView view, float scale, double duration = 1.0, bool repeat = true)
{
var animation = CABasicAnimation.FromKeyPath("transform.scale");
animation.Duration = duration;
animation.To = NSNumber.FromFloat(scale);
animation.TimingFunction = CAMediaTimingFunction.FromName(CAMediaTimingFunction.EaseInEaseOut);
animation.AutoReverses = true;
animation.RepeatCount = repeat ? float.MaxValue : 0;
view.Layer.AddAnimation(animation, "pulse");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment