标签:
上一个是绘制简单图形,这一篇学习绘制文字、图像
//获取画布 CGContextRef context=UIGraphicsGetCurrentContext(); //设置边框颜色 CGContextSetStrokeColorWithColor(context, [UIColor redColor].CGColor); //文字绘制 两种绘制方法 NSString *text=@"我是崔彦威"; NSDictionary *dic=@{NSFontAttributeName:[UIFont systemFontOfSize:20],NSForegroundColorAttributeName:[UIColor redColor]}; [text drawInRect:CGRectMake(0, 0, 200, 20) withAttributes:dic]; [text drawAtPoint:CGPointMake(200, 0) withAttributes:dic]; //图片绘制 UIImage *img=[UIImage imageNamed:@"img.jpg"]; //在矩形中绘制 // [img drawInRect:CGRectMake(20, 20, 120, 120)]; //以点开始绘制 // [img drawAtPoint:CGPointMake(20, 20)]; //平铺绘图 [img drawAsPatternInRect:CGRectMake(20, 20, 240, 300)];
标签:
原文地址:http://www.cnblogs.com/cuiyw/p/4401907.html