-(UIImage *)CSImage:(UIImage *)img AddText:(
NSString
*)text
{
UIImageView *view = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, img.size.width, img.size.height)];
view.image = img;
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0,0,0,0)];
[label setNumberOfLines:0];
label.lineBreakMode = UILineBreakModeWordWrap;
NSString
*s = text;
UIFont *font = [UIFont fontWithName:@
"Arial"
size:12];
CGSize size = CGSizeMake(320,2000);
CGSize labelsize = [s sizeWithFont:font constrainedToSize:size lineBreakMode:UILineBreakModeWordWrap];
label.frame = CGRectMake(0,0, labelsize.width, labelsize.height);
[view addSubview:label];
return
[
self
convertViewToImage:view];
}
-(UIImage*)convertViewToImage:(UIView*)v
{
CGSize s = v.bounds.size;
UIGraphicsBeginImageContextWithOptions(s,
NO
, [UIScreen mainScreen].scale);
CGContextRef context = UIGraphicsGetCurrentContext();
[v.layer renderInContext:context];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
v.layer.contents =
nil
;
return
image;
}