title: Xamarin forms gradient frame renderer for iOS
body: <p>i am creating a custom renderer for Xamarin.Forms Frame control to enable extended functionality like gradient background.</p>
  
  <p>for now i got it to work somehow on iOS but i am working on the android version too.</p>
  
  <p>First i tried to override the SetupLayer method as it is in the default frame renderer <a href="https://github.com/xamarin/Xamarin.Forms/blob/master/Xamarin.Forms.Platform.iOS/Renderers/FrameRenderer.cs" rel="nofollow noreferrer">see here</a>, and add a sublayer there </p>
  
  <p>The way i got it to work was to override Draw method and add a sublayer to the frame view and set the frame layer background to UIColor.Clear.</p>
  
  <p>The issue that i got is that controls i put inside of frame and also the gradient is somehow faded like there is some layer blending stuff going on. something like .5 opacity.</p>
  
  <p>Any advice how to get the Layer behind (Gradient) fully opaque?</p>
  
  <p>Am i doing it wrong ?</p>
  
  <p>Thanks in advance.</p>
  
  <p><strong>Update :</strong> I had removed unnecessary code from sample for not creating confusion, the issue i am facing is understand how layers blending work in iOS, as the top-layers blend with added gradient layer and look more faded than normal frame.</p>
  
  <pre><code> //not working
   private void SetupLayer()
      {  
   *** 
   var gl = new CAGradientLayer
          {
              StartPoint = new CGPoint(0, 0),
              EndPoint = new CGPoint(1, 1),
              Frame = rect,
              Colors = new CGColor[]
              {
                      _gradinetControl.StartColor.ToCGColor(),
                      _gradinetControl.EndColor.ToCGColor()
              },
              CornerRadius = _gradinetControl.CornerRadius
          };
  
          Layer.BackgroundColor = UIColor.Clear.CGColor;
  
         Layer.InsertSublayer(gl,0);
  ***
  }
  </code></pre>
  
  <p>*    </p>
  
  <pre><code>//working but strange fade blending    
  public override void Draw(CGRect rect)
      {           
          var gl = new CAGradientLayer
          {
              StartPoint = new CGPoint(0, 0),
              EndPoint = new CGPoint(1, 1),
              Frame = rect,
              Colors = new CGColor[]
              {
                      _gradinetControl.StartColor.ToCGColor(),
                      _gradinetControl.EndColor.ToCGColor()
              },
              CornerRadius = _gradinetControl.CornerRadius
          };
  
         NativeView.Layer.BackgroundColor = UIColor.Clear.CGColor;
         NativeView.Layer.InsertSublayer(gl,0);           
         base.Draw(rect);
      }
  </code></pre>