UIView.Draw(CGRect) 메서드

정의

전달된 사각형 내에서 뷰를 그립니다.

[Foundation.Export("drawRect:")]
[ObjCRuntime.ThreadSafe]
public virtual void Draw (CoreGraphics.CGRect rect);
abstract member Draw : CoreGraphics.CGRect -> unit
override this.Draw : CoreGraphics.CGRect -> unit

매개 변수

rect
CGRect

그릴 RectangleF입니다.

특성

설명

메서드를 Draw(CGRect) 직접 호출하면 안 됩니다. 실행 루프 처리 중에 iOS에서 호출됩니다. 실행 루프를 통해 처음으로 호출됩니다. 그런 다음 또는 을 호출 SetNeedsDisplayInRect(CGRect)SetNeedsDisplayInRect(CGRect)하여 보기가 디스플레이가 필요한 것으로 표시될 때마다 요청 시 호출됩니다.

코어 그래픽은 픽셀이 아닌 디바이스 독립적 지점을 사용합니다. 이렇게 하면 그리기 코드가 서로 다른 해상도 간에 스케일링할 수 있습니다. 예를 들어 Retina 디스플레이에서 1포인트는 2픽셀과 동일하지만 Retina가 아닌 디스플레이에서는 1포인트가 1픽셀에 해당합니다.

public override void Draw (RectangleF rect)
{
    base.Draw (rect);

    var context = UIGraphics.GetCurrentContext ();

    context.SetLineWidth(4);
    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)});

    path.CloseSubpath();

    context.AddPath(path);		
    context.DrawPath(CGPathDrawingMode.FillStroke);
}

백그라운드 스레드에서 사용할 수 있습니다.

적용 대상