UIView.Draw(CGRect) UIView.Draw(CGRect) Method


Draws the view within the passed-in rectangle.

public virtual void Draw (CoreGraphics.CGRect rect);
abstract member Draw : CoreGraphics.CGRect -> unit
override this.Draw : CoreGraphics.CGRect -> unit


CGRect CGRect

The RectangleF to draw.


The Draw(CGRect) method should never be called directly. It is called by iOS during run loop processing. The first time through the run loop, it is called. After that, it will be called on demand whenever the view has been marked as needing display by calling SetNeedsDisplayInRect(CGRect) or SetNeedsDisplayInRect(CGRect).

Core Graphics uses device independent points rather than pixels. This allows drawing code to scale between different resolutions. For example, on a Retina display, 1 point is equivalent to 2 pixels, while on non-Retina displays, 1 point corresponds to 1 pixel.

public override void Draw (RectangleF rect)
    base.Draw (rect);
var context = UIGraphics.GetCurrentContext ();

UIColor.Red.SetFill ();
UIColor.Blue.SetStroke ();

var path = new CGPath ();

path.AddLines(new PointF[]{
new PointF(100,200),
new PointF(160,100), 
new PointF(220,200)});




This can be used from a background thread.

Applies to