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);//繪製
        } 
    }
}
相關文章
相關標籤/搜索