How to create the shadow (pulse?) effect as in the gif below in a UIButton or UIImage in Xamarin.iOS?
How to create the shadow (pulse?) effect as in the gif below in a UIButton or UIImage in Xamarin.iOS?
You can call this function below, as follows:
Shine(true, meuBotao);
// muito código
Shine(false, meuBotao);
The function has the following code:
using MonoTouch.CoreGraphics;
using MonoTouch.CoreAnimation;
void Shine(bool active, UIView view) {
if (view == null)
throw new ArgumentNullException ("view");
if (active) {
view.Layer.ShadowColor = UIColor.Blue.CGColor;
view.Layer.ShadowOpacity = 0.0f;
view.Layer.ShadowRadius = 6.0f;
view.Layer.ShadowOffset = SizeF.Empty;
view.Layer.MasksToBounds = false;
var glow = CABasicAnimation.FromKeyPath("shadowOpacity");
glow.AutoReverses = true;
glow.Duration = 0.5;
glow.To = NSNumber.FromDouble (0.9);
glow.RepeatCount = int.MaxValue;
view.Layer.AddAnimation (glow, "glow");
} else {
view.Layer.RemoveAnimation ("glow");
if (view.Layer.ShadowColor == UIColor.Blue.CGColor) {
view.Layer.ShadowColor = UIColor.Clear.CGColor;
view.Layer.ShadowOpacity = 0.0f;
view.Layer.ShadowRadius = 0.0f;
view.Layer.ShadowOffset = SizeF.Empty;
view.Layer.MasksToBounds = false;
}
}
}
var shadowView = new UIView(textView.Frame);
shadowView.BackgroundColor = UIColor.White;
shadowView.Layer.ShadowColor = UIColor.DarkGray.CGColor;
shadowView.Layer.ShadowOpacity = 1.0f;
shadowView.Layer.ShadowRadius = 6.0f;
shadowView.Layer.ShadowOffset = new System.Drawing.SizeF(0f, 3f);
shadowView.Layer.ShouldRasterize = true;
shadowView.Layer.MasksToBounds = false;
Add(shadowView);
Add(textView);
What do you want to do next?