【iPhone Development】对图片加入特定水印的方法

来源:互联网 发布:sql添加数据 编辑:程序博客网 时间:2024/06/05 09:48
对图片加入特定水印的方法


iphone拍照后会有一些信息需要显示在图片上,上传或是打印,就是所谓的水印那样,可以通过下面的代码实现:


    //image是你要增加水印的底图    UIGraphicsBeginImageContext(image.size);    CGContextRef context = UIGraphicsGetCurrentContext();//设置水印颜色    [[UIColor whiteColor] set];    [title drawInRect:CGRectMake((image.size.width-[title sizeWithFont:font].width)/2+8, -30+(30-[title sizeWithFont:font].height)/2, 100, 30) withFont:font];        //获得加好水印的图片    result = UIGraphicsGetImageFromCurrentImageContext();    UIGraphicsEndImageContext();