I’m trying to create a “generic” renderer for iOS and I have trouble figuring out the dimensions of the renderer.
The class of the renderer in the PCL is very simple and the only “peculiar” is that inherits from a View since I want to have it as a generic renderer
public class ExampleView : View { }
In the XAML, it is also very typical
<renderers:ExampleView />
The definition of the renderer in the iOS project is the following
public class ExampleRenderer : ViewRenderer<ExampleView, UIView>
{
protected override void OnElementChanged(ElementChangedEventArgs<ExampleView> e)
{
base.OnElementChanged(e);
if (Control == null)
{
SetNativeControl(new UIView(new CGRect(0, 0, 0, 300)));
}
}
}
The interesting part here is that the class inherits from ViewRenderer<ExampleView, UIView>
It seems that although I specify that the width of the render to be 0, the actual renderer takes the entire width of the page.
In fact whatever value I put as width, will be disregarded, and the renderer will occupy the entire page.
This is not bad, it is unintentional and this is what bother me. (or Am I doing something wrong?)
So the question here is how can find in my custom render, the width that occupies?