我正在将文本写入图像,如下所示:
-(UIImage *)addLabelToImage:(UIImage *)img
{
UIFont *font = [UIFont boldSystemFontOfSize:20];
UIGraphicsBeginImageContext(img.size);
[img drawInRect:CGRectMake(0, 0,img.size.width,img.size.height)];
CGRect rect = CGRectMake(60, 550, img.size.width, img.size.height);
[[UIColor whiteColor] set];
[[NSString stringWithFormat:@"%@, %@", [[NSUserDefaults standardUserDefaults] valueForKey:@"whatever"], [[NSUserDefaults standardUserDefaults] valueForKey:@"whatever2"]] drawInRect:CGRectIntegral(rect) withFont:font];
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return newImage;
}
我将如何在此文本中添加阴影?我知道我可以将文本重绘为移动几个像素的黑色文本,但有没有更简单的方法?
干杯,乔治