由于业务需要, 图片需要更新文本, 而此图片又需要保存. 所以使用图片上绘制文字. (也就是UIview 转 UIImageView).
但是这种情况下, 在retain 高清屏显示的时候, 会出现图片像素降低, 失真的情况.
故而找了一下解决方案, 在此记录一下.
//图片添加文字
+ (UIImage )imageWithText:(NSString )text
textFont:(NSInteger)fontSize
textColor:(UIColor *)textColor
textFrame:(CGRect)textFrame
originImage:(UIImage *)image
imageLocationViewFrame:(CGRect)viewFrame {if (!text) { return image; } if (!fontSize) { fontSize = 15; } if (!textColor) { textColor = [UIColor blackColor]; } if (!image) { return nil; } if (viewFrame.size.height==0 || viewFrame.size.width==0 || textFrame.size.width==0 || textFrame.size.height==0 ){return nil;} NSString *mark = text; CGFloat height = [mark size