I have created a viewcontroller and have added some labels and a button to the view using the interface builder.
I am trying to add a rounded white border to the view so I am building a view via code using
//http://spazzarama.com/2011/01/08/monotouch-uiview-with-curved-border-and-shadow/
public class WhiteRectangle:UIView
{
// Constructor used when view is defined in InterfaceBuilder
public WhiteRectangle (IntPtr handle) : base(handle)
{
this.CreateCurveAndShadow();
}
// Constructor to use when creating in code
public WhiteRectangle (System.Drawing.RectangleF frame) : base(frame)
{
this.CreateCurveAndShadow();
}
private void CreateCurveAndShadow()
{
// MasksToBounds == false allows the shadow to appear outside the UIView frame
this.Layer.MasksToBounds = false;
this.Layer.CornerRadius = 10;
this.Layer.ShadowColor = UIColor.DarkGray.CGColor;
this.Layer.ShadowOpacity = 1.0f;
this.Layer.ShadowRadius = 6.0f;
this.Layer.ShadowOffset = new System.Drawing.SizeF(0f, 3f);
}
}
Within my ViewControllers ViewDidLoad
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
var view = new WhiteRectangle(new System.Drawing.RectangleF(10, 10, 300, 300));
view.BackgroundColor = UIColor.White;
View.AddSubview (view);
}
Now my problem is the view I am creating as you would expect is being added after the view created in the interface builder. Is it possible to set the order of the view?
I have tried
View.Subviews[0].SendSubviewToBack(View.Subviews[1]);
View.Subviews[1].SendSubviewToBack(View.Subviews[0]);
Neither work
I was close. If anyone else is stuck on the same thing this worked