Forum Xamarin.Forms


The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

Custom Renderer to Override View Draw on iOS

Hello everyone!

Recently I created a custom renderer for android to draw a graphic Inheriting from View..
On android I simply overwritten the Draw method, and drew everything I need (arcs, circles and text) using canvas.

Now i went to iOS and ran into a problem.
In all the settings I've used and found over the internet, none of them have reached the override Draw method.

Follow the latest code i tried for iOS CustomRenderer:

using CoreGraphics;
using UIKit;
using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;

[assembly: ExportRenderer(typeof(MyProjectName.CustomPieChart), typeof(MyProjectName.iOS.Renderers.CustomPieChartRenderer))]
namespace MyProjectName.iOS.Renderers
    class CustomPieChartRenderer : ViewRenderer<CustomPieChart, UIView>
        private int ScaleFactor = 1;

        protected override void OnElementChanged(ElementChangedEventArgs<CustomPieChart> e)
            if (Control == null)
                var circleDotView = new UIView();

        protected override void OnElementPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
            base.OnElementPropertyChanged(sender, e);

            if (e.PropertyName == CustomPieChart.DataValuesProperty.PropertyName)

        public override void Draw(CGRect rect)

My custom control is:
public class CustomPieChart : View

My breakpoint never reachs the Draw method.
All my other custom renderes (without draw) are working perfect, those for Android too, including with draw.

Could someone tell me what I'm doing wrong?

Best Answer

  • LeonardoAlmeida.4638LeonardoAlmeida.4638 USUniversity ✭✭
    Accepted Answer

    I found a simple solution:

    I changed my control base to BoxView instead of View, and my customrenderer reached the Draw.


Sign In or Register to comment.