标签:
用UIGraphics进行2D图像渲染 不要用UIGraphicsBeginImageContext(size); 不然图片会模糊
- (UIImage *)createShareImage:(NSString *)str name:(NSString *)name number:(NSString *)number grade:(NSString *)grade
{
UIImage *image = [UIImage imageNamed:@"shareGrade"];
CGSize size=CGSizeMake(image.size.width, image.size.height);//画布大小
UIGraphicsBeginImageContextWithOptions(size, NO, 0.0);
[image drawAtPoint:CGPointMake(0, 0)];
//获得一个位图图形上下文
CGContextRef context=UIGraphicsGetCurrentContext();
CGContextDrawPath(context, kCGPathStroke);
//画 打败了多少用户
[str drawAtPoint:CGPointMake(30, image.size.height*0.65) withAttributes:@{NSFontAttributeName:[UIFont fontWithName:@"Arial-BoldMT" size:30],NSForegroundColorAttributeName:[UIColor whiteColor]}];
//画自己想画的内容。。。。。
//返回绘制的新图形
UIImage *newImage=UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return newImage;
}
标签:
原文地址:http://www.cnblogs.com/android-wuwei/p/4896946.html