Last Updated: February 25, 2016
·
2.073K
· segphault

Building custom components for Xamarin Studio's new iOS designer

I wrote a detailed, hands-on introduction to using the new iOS designer in Xamarin Studio. The blog post explains how to build custom user interface components that will be live-rendered on the design surface:

[Register("RectSample")]
public class RectSample : UIView
{
    public RectSample () {}

    public RectSample (IntPtr handle) : base (handle) {}

    [Export, Browsable(true)]
    public int Red { get; set; }

    [Export, Browsable(true)]
    public int Green { get; set; }

    [Export, Browsable(true)]
    public int Blue { get; set; }

    public override void Draw (RectangleF rect)
    {
        var path = UIBezierPath.FromRoundedRect(rect.Inset(1, 1), 4);

        UIColor.FromRGB (Red, Green, Blue).SetFill ();
        path.Fill();

        UIColor.Black.SetStroke();
        path.Stroke();
    }
}