IOS用CGContextRef画各种图形
//覆盖drawRect方法,你可以在此自定义绘画和动画 -(void)drawRect:(CGRect)rect { //AnopaquetypethatrepresentsaQuartz2Ddrawingenvironment. //一个不透明类型的Quartz2D绘画环境,相当于一个画布,你可以在上面任意绘画 CGContextRefcontext=UIGraphicsGetCurrentContext(); /*写文字*/ CGContextSetRGBFillColor(context,1,0,0,1.0);//设置填充颜色 UIFont*font=[UIFontboldSystemFontOfSize:15.0];//设置 [@"画圆:"drawInRect:CGRectMake(10,20,80,20)withFont:font]; [@"画线及孤线:"drawInRect:CGRectMake(10,80,100,20)withFont:font]; [@"画矩形:"drawInRect:CGRectMake(10,120,80,20)withFont:font]; ...