用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;
}