//
// zuoView.swift
// swift 仓库
//
// Created by zuo on 16/3/7.
// Copyright © 2016年 zuo. All rights reserved.
//
import UIKit
class zuoView: UIView {
override func 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)
}
}