xamarin.ios 画矩形

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);//绘制
        } 
    }
}

猜你喜欢

转载自my.oschina.net/u/2287505/blog/1787961