IOS第17天(1,Quartz2D图片水印)
2015-09-01 17:15
495 查看
****图片 水印
#import "HMViewController.h" @interface HMViewController () @property (weak, nonatomic) IBOutlet UIImageView *imageView; @end @implementation HMViewController - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. UIImage *oldImage = [UIImage imageNamed:@"img"]; // 开启上下文 // size 新的图片大小 // opaque YES 不透明 NO 透明 UIGraphicsBeginImageContextWithOptions(oldImage.size, NO, 0.0); [oldImage drawAtPoint:CGPointZero]; NSString *text = @"我要高薪 !"; NSDictionary *dict = @{ NSFontAttributeName : [UIFont systemFontOfSize:15], NSForegroundColorAttributeName : [UIColor redColor] }; [text drawAtPoint:CGPointMake(120, 170) withAttributes:dict]; // 获取新的图片 UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext(); // 关闭上下文 UIGraphicsEndImageContext(); _imageView.image = newImage; // 把图片转换成png格式的二进制数据 NSData *data = UIImagePNGRepresentation(newImage); // 写入桌面 [data writeToFile:@"/Users/apple/Desktop/newImage.png" atomically:YES]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } @end
相关文章推荐
- ios原生二维码扫描
- iOS CGAffineTransform详解
- 16.IOS 新消息通知提示-声音、震动
- IOS第16天(5,Quartz2D雪花)
- IOS第16天(4,Quartz2D柱状图)
- IOS第16天(3,Quartz2D饼图)
- IOS第16天(2,Quartz2D下载进度条)
- 14.IOS中系统唯一标识ID
- iOS KVC,KVO
- 4.极光推送解释的iOS本地通知
- 5.iOS 7 Background Remote Notification
- 2.iOS苹果推送-一些示例代码和注意的问题
- 1.iOS中的系统通知 自定义推送声音
- IOS开发-视频,音频,录音简单总结
- iOS开发系列--音频播放、录音、视频播放、拍照、视频录制
- IOS中nil/Nil/NULL的区别
- iOS-Quartz2D绘图的基础用法总结
- iOS中socket的使用
- iOS 设置导航栏 Navigationbar相关信息
- IOS-添加分段控件SegmentControl