public override void Draw(CGRect rect) { base.Draw(rect); this.LayoutIfNeeded(); RoundedShadowBoxView view = (RoundedShadowBoxView)Element; //rcv.HasShadow = false; view.Padding = new Thickness(0, 0, 0, 0); //this.BackgroundColor = rcv.FillColor.ToUIColor(); this.ClipsToBounds = true; this.Layer.BackgroundColor = view.FillColor.ToCGColor(); this.Layer.MasksToBounds = true; this.Layer.CornerRadius = (nfloat)view.RoundedCornerRadius; if (view.MakeCircle) { this.Layer.CornerRadius = (int)(Math.Min(Element.Width, Element.Height) / 2); } this.Layer.BorderWidth = 0; if (view.BorderWidth > 0 && view.BorderColor.A > 0.0) { this.Layer.BorderWidth = view.BorderWidth; this.Layer.BorderColor = new UIColor( (nfloat)view.BorderColor.R, (nfloat)view.BorderColor.G, (nfloat)view.BorderColor.B, (nfloat)view.BorderColor.A).CGColor; } }
protected override bool DrawChild(Canvas canvas, Android.Views.View child, long drawingTime) { if (Element is null) { return(false); } RoundedShadowBoxView view = (RoundedShadowBoxView)Element; this.SetClipChildren(true); view.Padding = new Thickness(0, 0, 0, 0); int radius = (int)(view.RoundedCornerRadius); if (view.MakeCircle) { radius = Math.Min(Width, Height) / 2; } radius *= 2; try { var path = new Path(); path.AddRoundRect(new RectF(0, 0, Width, Height), new float[] { radius, radius, radius, radius, radius, radius, radius, radius }, Path.Direction.Ccw); canvas.ClipPath(path); var result = base.DrawChild(canvas, child, drawingTime); canvas.Restore(); if (view.BorderWidth > 0) { // Draw a filled circle. var paint = new Paint(); paint.AntiAlias = true; paint.StrokeWidth = view.BorderWidth; paint.SetStyle(Paint.Style.Stroke); paint.Color = view.BorderColor.ToAndroid(); canvas.DrawPath(path, paint); paint.Dispose(); } path.Dispose(); return(result); } catch (Exception ex) { System.Console.Write(ex.Message); } return(base.DrawChild(canvas, child, drawingTime)); }