您的位置:首页 > 移动开发 > Swift

swift 绘图

2016-03-07 15:39 344 查看
//
// 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)

}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: