图片上写文字
2016-01-25 15:17
302 查看
+ (UIImage*)drawText:(NSString*)text inImage:(UIImage*)image atPoint:(CGPoint)point withFont:(UIFont *)font
{
UIGraphicsBeginImageContext(image.size);
[image drawInRect:CGRectMake(0,0,image.size.width,image.size.height)];
CGRect rect = CGRectMake(point.x, point.y, image.size.width, image.size.height);
[[UIColor blackColor] set];
[text drawInRect:CGRectIntegral(rect) withAttributes:@{NSFontAttributeName:font}];
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return newImage;
}
{
UIGraphicsBeginImageContext(image.size);
[image drawInRect:CGRectMake(0,0,image.size.width,image.size.height)];
CGRect rect = CGRectMake(point.x, point.y, image.size.width, image.size.height);
[[UIColor blackColor] set];
[text drawInRect:CGRectIntegral(rect) withAttributes:@{NSFontAttributeName:font}];
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return newImage;
}
相关文章推荐
- 深度学习2015年文章整理(CVPR2015)
- springmvc中@PathVariable和@RequestParam的区别
- Android 第三方应用监听home键
- LA3029
- MyEclipse的优化与快捷键的设置
- JavaScript arguments对象
- HTTP权威指南学习笔记
- nodejs 项目编译
- Python爬虫实战六之抓取爱问知识人问题并保存至数据库
- iOS 根据 crash 崩溃 报告的内存地址定位到代码位置
- PHPCMS代码生成器
- Json的介绍与使用
- POJ 1700
- linux vi命令保存
- Java Annotation注解语法
- SQL--工作中遇到的
- Delphi获取其它进程窗口句柄的3种方法
- 类的继承 保护继承和私有继承
- Android Studio安装:Unable to access Android SDK add-on list
- 299. Bulls and Cows ——猜数字游戏