代码如下:
- ( UIImage *)createShareImage:( NSString *)str name:( NSString *)name
{
//获取要加工的图片
UIImage *image = [ UIImage imageNamed : name ];
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 ( 0 , size.height/2-4.5 ) withAttributes : @{ NSFontAttributeName :[ UIFont fontWithName : @"Arial-BoldMT" size : 9 ], NSForegroundColorAttributeName :[ UIColor whiteColor ] } ];
// 返回绘制的新图形
UIImage *newImage= UIGraphicsGetImageFromCurrentImageContext ();
UIGraphicsEndImageContext ();
return newImage;
}