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

iOs画图 划线的三种方式

2015-06-29 11:48 381 查看
//

// SCHPic1.m

// Contextschtest1

//

// Created by tianshangrenjian on 15/6/29.

// Copyright (c) 2015年 tianshangrenjian. All rights reserved.

//

#import "SCHPic1.h"

@implementation SCHPic1

// Only override drawRect: if you perform custom drawing.

// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {

// Drawing code

CGContextRef ctx=UIGraphicsGetCurrentContext();

CGMutablePathRef path=CGPathCreateMutable();

CGPathMoveToPoint(path,
NULL, 0, 0);

CGPathAddLineToPoint(path,
NULL,
100, 100);

CGContextAddPath(ctx, path);

CGContextStrokePath(ctx);

CGContextMoveToPoint(ctx,
20,0);

CGContextAddLineToPoint(ctx,
100,
100);

CGContextStrokePath(ctx);

CGContextClosePath(ctx);

UIBezierPath *bpath=[[UIBezierPath
alloc]
init];

[bpath moveToPoint:CGPointMake(30,
0)];

[bpath addLineToPoint:CGPointMake(100,
100)];
[bpath
stroke];
}

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