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
// 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
相关文章推荐
- ios画图 划线的两种方式
- iOS IAP恢复
- iOS 隐藏状态栏
- iOS画图 圆形裁剪
- iOS画图 上下文栈的使用
- iOS 对相机及相册的操作
- iOS开发之Xcode6之后不再自动创建Pch预编译文件(解决unknown type name........)
- 画1像素的线
- iOS 如何 理解 代理
- IOS开发---获取用户当前地理坐标(最新)
- IOS调试技巧——异常断点
- iOS: 如何正确的绘制1像素的线
- 如何让iOS模拟器也能测试蓝牙4.0程序?
- 细数iOS上那些你绝对不会注意到的神细节
- ios-block循环引用简析
- iOS程序运行流程
- iOS自带扫描 和 生成二维码
- iOS应用性能调优的建议和技巧--中高级--王朋
- 如何添加真机调试的iOS设备
- 使用GTMBase64编码解码字符串