iOS在view中绘制不规则图形
2017-07-13 12:04
1776 查看
iOS绘制不规则图形,可以设置各个经过的点,以及是否有边框,是否有填充色等。
//----画三角形---- UIGraphicsBeginImageContext(cellView.bounds.size); //设置背景颜色 [[UIColor clearColor]set]; UIRectFill([cellView bounds]); //拿到当前视图准备好的画板 CGContextRef context = UIGraphicsGetCurrentContext(); //利用path进行绘制三角形 CGContextBeginPath(context);//标记 CGContextMoveToPoint(context, 71, 36);//设置起点 CGContextAddLineToPoint(context, 58, 44);//经过的点,可以多写几个点 CGContextAddLineToPoint(context, 71, 52);//重点 // CGContextClosePath(context);//路径结束标志,不写默认封闭 [[UIColor whiteColor] setFill]; //设置填充色 [[UIColor lightGrayColor] setStroke]; //设置边框颜色 CGContextDrawPath(context, kCGPathFillStroke);//绘制路径path //从Context中获取图像,并显示在界面上 UIImage *img = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); UIImageView *gifTriangleView = [[UIImageView alloc] initWithImage:img]; [cellView addSubview:gifTriangleView]; //----画三角形----
相关文章推荐
- iOS 绘制不规则图形,并且添加点击事件
- iOS--Quartz2D使用(自定义UIImageView控件、绘制基本图形)
- OpenPlug Studio应用在iOS的图形绘制效能是Adobe Flash Builder 4.5.1应用的4倍!
- ios开发图形绘制
- iOS -- 图形绘制(全)
- ios drawRect绘制图形
- IOS Quartz 各种绘制图形用法---实现画图片、写文字、画线、椭圆、矩形、棱形等
- IOS学习笔记 运用Quartz 2D框架绘制常见的图形(2)
- MFC在VIEW的Client区绘制图形
- SurfaceView与Canvas的结合实现简单的图形绘制与动画效果
- ios Quartz 各种绘制图形用法
- 11-UIKit(Storyboard、View的基本概念、绘制图形、UIBezierPath)
- Android隐喻(三) 图形绘制: Canvas、SurfaceView、Paint、Surface、SurfaceHolder、Bitmap
- IOS图形绘制基础
- iOS应用开发之免费2D图形绘制开源插件推荐
- IOS详解TableView——性能优化及手工绘制UITableViewCell
- ios开发图形绘制
- IOS绘制圆,直线,弧线,矩形,扇形,三角形,贝塞尔等图形
- Android 利用SurfaceView进行图形绘制
- IOS Quartz 各种绘制图形用法---实现画图片、写文字、画线、椭圆、矩形、棱形等