title: How to create gradient button background in xamarin forms for iOS
body: <p>Im creating an iPhone application in Xamarin forms which requires gradient button background. I have tried <code>CAGradientLayer</code>. But, it is not working for buttons. </p>
  
  <p>Can anyone help me to solve this issue?
  This is my button renderer:</p>
  
  <pre><code>    protected override void OnElementChanged (ElementChangedEventArgs&lt;Button&gt; e)
      {
          base.OnElementChanged (e);
  
          if(e.OldElement == null)
          {
  
              btn = (UIButton) Control;
              btn.Frame = new RectangleF (0, 0, (float)this.Element.WidthRequest, (float)this.Element.HeightRequest);
              CAGradientLayer btnGradient = new CAGradientLayer ();
              btnGradient.Frame = btn.Bounds;
              btnGradient.Colors = new CGColor[]{ Color.White.ToCGColor(), Color.FromHex("#0073BD").ToCGColor() };
              btn.Layer.InsertSublayer (btnGradient, 0);
              btn.Layer.MasksToBounds = true;
              btn.Layer.BorderColor = Color.FromHex("#0073BE").ToCGColor();
              btn.Layer.BorderWidth = 1;
              btn.SetTitleColor(Color.Black.ToUIColor (), UIControlState.Normal);
          }
      }
  </code></pre>