drawRect简单的绘图Demo
来源:互联网 发布:inspection是什么软件 编辑:程序博客网 时间:2024/06/10 08:35
-(void)drawRect:(CGRect)rect{
//[self drawline ];
//[self drawball];
//[self drawxunLine];
//[self drawxuboll];
//绘制上下文方式画一条线
[selfdrawlineGrap];
}
-(void)drawxuboll{
//1 获取上下文
CGContextRef ref =UIGraphicsGetCurrentContext();
//路径
UIBezierPath *path = [UIBezierPathbezierPathWithOvalInRect:CGRectMake(10,10, 50,90)];
//颜色边线
[[UIColor redColor]setStroke];
//填充颜色
[[UIColor yellowColor]setFill];
//线宽
CGContextSetLineWidth(ref,4);
//虚线
CGFloat lengths[] = {7,11};
CGContextSetLineDash(ref,0, lengths, 2);
//将路径添加到上下文中
CGContextAddPath(ref, path.CGPath);
//end:将上下文渲染
CGContextDrawPath(ref,kCGPathFillStroke);
}
-(void)drawxunLine{
//另外一中画横线的方法
//创建上下文
CGContextRef ref =UIGraphicsGetCurrentContext();
//创建路径
UIBezierPath *path1 = [UIBezierPathbezierPath];
//创建七点
[path1 moveToPoint:CGPointMake(1,0)];
//增加一条线段到某点
[path1 addLineToPoint:CGPointMake(99,99)];
//颜色
[[UIColor redColor]set];
//线宽
CGContextSetLineWidth(ref,4);
//虚线
CGFloat lengths[] = {4,2};
CGContextSetLineDash(ref,0, lengths, 2);
//将路径关联到上下文
CGContextAddPath(ref, path1.CGPath);
//end : 渲染
// CGContextStrokePath(ref); //stroke
CGContextDrawPath(ref,kCGPathFillStroke);//
}
-(void)drawball{
//宽高相等为圆形 ,宽高不相等为椭圆形
UIBezierPath *path = [UIBezierPathbezierPathWithOvalInRect:CGRectMake(88,0, 88,108)];
///颜色set = fill+stroke同时执行
// [[UIColor redColor]set];
// stroke绘制外边框的颜色
[[UIColor redColor]setStroke];
//fill 绘制图形里边的填充颜色
[[UIColor yellowColor]setFill];;
path.lineWidth = 5;
//绘制
[path stroke];
[path fill];
}
-(void)drawline{
//绘制一条横线
//用贝塞尔曲线类(路径)
UIBezierPath *path =[UIBezierPathbezierPath];
//创建起点坐标
[path moveToPoint:CGPointMake(0,0)];
//增加一条线段到某个点
[path addLineToPoint:CGPointMake(33,33)];
//设置先段的颜色
[[UIColor redColor]set];
//设置线宽
path.lineWidth =4;
//end: 绘制上去
[path stroke];
UIBezierPath *path1 = [UIBezierPathbezierPath];
[path1 moveToPoint:CGPointMake(20,20)];
[path1 addLineToPoint:CGPointMake(100,100)];
[path1 addLineToPoint:CGPointMake(40,120)];
[path1 closePath];
[[UIColor orangeColor]set];
path1.lineWidth = 10;
[path1 stroke];
}
-(void)drawlineGrap{
CGContextRef ref =UIGraphicsGetCurrentContext();
UIBezierPath *path = [UIBezierPathbezierPath];
[path moveToPoint:CGPointMake(0,0)];
[path addLineToPoint:CGPointMake(30,30)];
[[UIColor blueColor]set];
CGContextSetLineWidth(ref,4);
CGContextAddPath(ref, path.CGPath);
CGContextDrawPath(ref,kCGPathFillStroke);
}
- drawRect简单的绘图Demo
- drawRect绘图
- 绘图drawrect
- 一个使用drawElements绘图的简单Demo
- drawRect 中CGContextRef绘图的应用
- 获取drawRect绘图后的截图
- Android2.3中C++编写的简单的绘图demo
- drawRect方法绘图
- iOS 绘图(drawrect)图片裁剪的红色框框
- iOS的绘图之drawRect和drawLayer:inContext
- drawRect:一点绘图知识总结
- iOS DrawRect简单使用
- iOS drawRect方法中在超过当前view边界的位置绘图
- 关于view的drawRect多次被调用出现绘图重叠问题
- drawRect绘制图片、箭头、矩形(Demo)
- android 绘图--简单手写绘图后保存为图片(demo)
- 定时器简单的Demo
- 简单的Emoji demo
- 小说阅读器
- 记录神经网络中一些小知识点
- Java-空字符串""和null的区别
- 原始经纬度转百度地图定位并显示地理位置
- Jsp 标签之<c:foreach>循环
- drawRect简单的绘图Demo
- Spring IOC&DI
- 如何锁定 input 内容不可修改
- Python内置函数学习(4)-basestring()
- 51单片机 指纹模块 总结(1)
- Android练习-----列表视图(ListView)(通过继承ListActivity实现列表视图)
- JSTL标签库与EL表达式
- 获取spring中的用户属性
- CSU 1216 异或最大值【字典树】