protected override void OnElementChanged(ElementChangedEventArgs <Button> e)
        {
            base.OnElementChanged(e);

            if (e.OldElement == null)
            {
                caller = e.NewElement as GradientButton;

                gradient              = new CAGradientLayer();
                gradient.Frame        = Control.Bounds;
                gradient.CornerRadius = Control.Layer.CornerRadius = caller.CornerRadius;

                gradient.Colors = new CGColor[]
                {
                    caller.StartColor.ToCGColor(),
                        caller.EndColor.ToCGColor(),
                };

                if (caller.ShadowColor != null)
                {
                    Control.Layer.ShadowRadius  = (nfloat)caller.ShadowRadius;
                    Control.Layer.ShadowColor   = caller.ShadowColor.ToCGColor();
                    Control.Layer.ShadowOffset  = new CGSize(0.0f, caller.ShadowOffset);
                    Control.Layer.ShadowOpacity = caller.ShadowOpacity;
                    Control.Layer.MasksToBounds = false;
                }
                Control.SetTitleColor(caller.DisabledTextColor.ToUIColor(), UIControlState.Disabled);

                Control?.Layer.InsertSublayer(gradient, 0);
            }
        }
Beispiel #2
0
        protected override void OnElementChanged(ElementChangedEventArgs <Button> e)
        {
            base.OnElementChanged(e);

            if (Control != null)
            {
                caller = e.NewElement as GradientButton;
                SetButtonDisableState();
                SetGradientAndRadius();
            }
        }