xamarin.ios draw rectangle

using System;
using Foundation;
using UIKit;
using System.Drawing;  
using CoreGraphics; 

namespace ceshis
{
    public class EmptyClass:UIView 
    {

        public EmptyClass()
        {
        }  
      //划线  
        public override void Draw(CoreGraphics.CGRect rect)  
        {  
            base.Draw(rect);  
            CGContext cGContext = UIGraphics.GetCurrentContext();
            CGPoint[] sPoints = {new CGPoint(100,100),new CGPoint(200, 80),
            new CGPoint(300, 100),new   CGPoint(100, 200)};//矩形的4个点
            cGContext.AddLines(sPoints);
            cGContext.ClosePath();//封闭图形
            cGContext.SetFillColor(UIColor.Red.CGColor);//填充颜色
            cGContext.DrawPath(CGPathDrawingMode.EOFill);//绘制
        } 
    }
}

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325051560&siteId=291194637