swift 绘图

来源:互联网 发布:cf冰域炸服器软件 编辑:程序博客网 时间:2024/04/29 13:59

//

//  zuoView.swift

//  swift 仓库

//

//  Created by zuo on 16/3/7.

//  Copyright © 2016 zuo. All rights reserved.

//


import UIKit


class zuoView:UIView {


    overridefunc drawRect(rect: CGRect) {

        

        super.drawRect(rect)

        let context =UIGraphicsGetCurrentContext()

        CGContextSetLineWidth(context,3)

        CGContextSetStrokeColorWithColor(context,UIColor.purpleColor().CGColor)

        

        

        

        CGContextMoveToPoint(context,0, 0)

        CGContextAddLineToPoint(context,150, 150)

        

        //填充它时,消耗了路径

        CGContextDrawPath(context,CGPathDrawingMode.Stroke)

        

        //绘制矩形

        

        CGContextMoveToPoint(context,50 ,50)

        

//

        let rect =CGRectMake(60,60, 100,100)

        

        CGContextAddRect(context, rect)

       

        

        

        


      CGContextSetFillColorWithColor(context,UIColor.purpleColor().CGColor)

         CGContextDrawPath(context,CGPathDrawingMode.Fill)

        

    }


}

0 0
原创粉丝点击