主要用時驗證照片的真實性 以及照片版權(quán)等類信息
+(UIImage)YHWaterMarkImage:(UIImage)img withName:(NSString *)name
{
NSString* mark = name;
int w = img.size.width;
int h = img.size.height;
UIGraphicsBeginImageContext(img.size);
[img drawInRect:CGRectMake(0, 0, w, h)];
NSDictionary *attr = @{
NSFontAttributeName: [UIFont boldSystemFontOfSize:13],? //設置字體
NSForegroundColorAttributeName : [UIColor cyanColor]? //設置字體顏色
};
[mark drawInRect:CGRectMake(0, img.size.height-20,img.size.width? ,20) withAttributes:attr];
UIImage *aimg = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return aimg;
}
第一個參數(shù)傳當前獲取到的照片UIImage
第二個參數(shù)就是你想添加的水印字段
這邊我個人添加的是系統(tǒng)當前時間(NSDate)
效果圖如下
