iOS画线
2015-07-09 17:04
309 查看
iOS画线(直线,折线,多个线段)
UIImageView *imageView=[[UIImageView alloc] initWithFrame:CGRectMake(5, 44+HEIGHT_ADJUST_IOS7_BAR+5, SCREENSIZE.width-10, 175-49)]; imageView.backgroundColor = [UIColor whiteColor]; self.view.backgroundColor = COLOR_HEX_RGB(0xefefef); [self.view addSubview:imageView]; [self.view sendSubviewToBack:imageView]; UIGraphicsBeginImageContext(imageView.frame.size); [imageView.image drawInRect:CGRectMake(0, 0, imageView.frame.size.width, imageView.frame.size.height)]; CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapSquare); CGContextSetLineWidth(UIGraphicsGetCurrentContext(), 0.1); //线宽 CGContextSetAllowsAntialiasing(UIGraphicsGetCurrentContext(), YES); CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), 0.6, 0.6, 0.6, 1.0); //颜色 CGContextBeginPath(UIGraphicsGetCurrentContext()); CGContextMoveToPoint(UIGraphicsGetCurrentContext(), 15, 95-49); //起点坐标 CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), SCREENSIZE.width-15, 95-49); //如果是折线,一直写下去,就不停的拐弯。 CGContextMoveToPoint(UIGraphicsGetCurrentContext(), SCREENSIZE.width-15, 135-49); //另一个起点坐标,重新开始了一条线 CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), 15, 135-49); //终点坐标 CGContextStrokePath(UIGraphicsGetCurrentContext()); imageView.image=UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext();
相关文章推荐
- iOS应用内购买报错:invalidProductIdentifiers
- 自定义iOS列表索引控件
- 【iOS开发系列】性能优化建议和技巧
- iOS编程 摇一摇 震动
- iOS流媒体开发的资料
- Github上600多个iOS开源项目分类及介绍
- iOS 自定义动态键盘
- iOS 9 适配系列教程
- IOS - 会员中心页面和逻辑
- iOS开发系列--通知与消息机制
- ios项目(十四)
- ios系列——导航条整理
- 中文 iOS/Mac 开发博客列表
- IOS中NSUserDefaults的用法(轻量级本地数据存储)
- iOS 深复制&浅复制
- iOS学习之iOS沙盒(sandbox)机制和文件操作(一)
- iOS核心动画高级技巧之CALayer(一)
- IOS 手势学习(点击,长按,轻扫,拖拽,旋转,捏合缩放)
- iOS判断应用是否首次启动
- iOS 启动图相关