Following the example from the previous recipe, we will draw a circle and square on the screen.
Create a new Single View Application in Xamarin Studio and name it DrawShapeApp
. Add a custom view to the project, like we did in the previous task, and name it DrawingView
.
Perform the following steps:
Override the
Draw
method of theDrawingView
class and implement it with the following code:CGContext context = UIGraphics.GetCurrentContext(); context.SetFillColorWithColor(UIColor.Blue.CGColor); context.SetShadow(new SizeF(10f, 10f), 5f); context.AddEllipseInRect(new RectangleF(100f, 100f, 100f, 100f)); context.FillPath(); context.SetFillColorWithColor(UIColor.Red.CGColor); context.AddRect(new RectangleF(150f, 150f, 100f, 100f)); context.FillPath();
In the
ViewDidLoad
method of theDrawShapeAppViewController
class, initialize and display the view with the following code:DrawingView drawView = new DrawingView(new RectangleF(0f, 20f, this.View.Bounds.Width...