关于CGContextRef画图
来源:互联网 发布:arm c语言编程实例 编辑:程序博客网 时间:2024/05/29 17:39
1.此处方法是得到一个矩形
-(void)drawRect:(CGRect)rect
{
//获得当前画板
CGContextRefcontext=UIGraphicsGetCurrentContext();
//设置线条的颜色
CGContextSetRGBStrokeColor(context,0.2,0.2,0.2,1.0);
//设置线条的宽度
CGContextSetLineWidth(context,1);
//设置所选取的区域
CGContextAddRect(context,CGRectMake(1,1,self.bounds.size.width-1,self.bounds.size.height-1));
//开始画线
CGContextStrokePath(context);
[super drawRect:rect];
}
2.此处方法得到一条线
-(void)drawRect:(CGRect)rect{
CGContextRef context =UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context,[UIColorcolorWithRed:130/255.0green:130/255.0blue:130/255.0alpha:1.0].CGColor);
CGContextFillRect(context,CGRectMake(0,self.bounds.size.height-0.8,self.bounds.size.width,0.8));
}
3.此处方法得到一个圆形区域
-(void)drawRect:(CGRect)rect
{
CGContextRefcontext=UIGraphicsGetCurrentContext();
CGContextSetRGBStrokeColor(context,0.2,0.2,0.2,1.0);
CGContextSetLineWidth(context,1);
CGContextAddArc(context,self.bounds.size.width/2,self.bounds.size.height/2,self.bounds.size.width/2,0,M_PI*2,0);
CGContextDrawPath(context,kCGPathStroke);
self.clipsToBounds =YES;
self.layer.cornerRadius =self.bounds.size.width/2;
[super drawRect:rect];
}
- 关于CGContextRef画图
- CGContextRef画图
- CGContextRef画图
- IOS CGContextRef画图小结
- iOS CGContextRef画图小结
- iOS CGContextRef画图小结
- iOS CGContextRef画图小结
- iOS CGContextRef画图小结
- iOS CGContextRef画图小结
- 画图CGContextRef相关
- iOS CGContextRef画图小结
- iOS用CGContextRef画图
- CGContextRef画图小结
- iOS用CGContextRef画图
- CGContextRef画图了解(转载)
- ios开发使用CGContextRef画图
- CGContextRef 与CGMutablePathRef画图用法
- iOS开发 CGContextRef画图使用
- 手把手教你开发chrome扩展一:开发Chrome Extenstion其实很简单
- Implementing Redlines(Android)
- AdoConnection连接池的使用
- 前端 Html 2
- 【原创】k8s源码分析-----Mux And Broadcaster
- 关于CGContextRef画图
- datatables使用记录
- windows删除顽固文件
- IOS开发之----Mac终端 常用命令
- JAVA基础(23) web.xml配置实例
- 关于htmlentities 、htmlspecialchars、addslashes的使用
- 玩转Python机器学习七步法
- 犯过的错误
- android6.0Okhttp网络请求