
//--- UIImageExtension.swift ---
//水印位置枚举
//添加水印方法
func waterMarkedImage(waterMarkText:String, corner:WaterMarkCorner = .BottomRight,

margin:CGPoint = CGPoint(x: 20照片英文水印样式, y: 20), waterMarkTextColor:UIColor = UIColor.whiteColor(),
waterMarkTextFont:UIFont = UIFont.systemFontOfSize(20),
backgroundColor:UIColor = UIColor.clearColor()) -> UIImage{
let textAttributes = [NSForegroundColorAttributeName:waterMarkTextColor,

NSFontAttributeName:waterMarkTextFont]
let textSize = NSString(string: waterMarkText).sizeWithAttributes(textAttributes)
var textFrame = CGRectMake(0, 0, textSize.width, textSize.height)
textFrame.origin = margin

textFrame.origin = CGPoint(x: imageSize.width - textSize.width - margin.x, y: margin.y)
textFrame.origin = CGPoint(x: margin.x, y: imageSize.height - textSize.height - margin.y)
textFrame.origin = CGPoint(x: imageSize.width - textSize.width - margin.x,
y: imageSize.height - textSize.height - margin.y)

// 开始给照片添加文字水印
UIGraphicsBeginImageContext(imageSize)
self.drawInRect(CGRectMake(0, 0,imageSize.width照片英文水印样式, imageSize.height))
NSString(string: waterMarkText).drawInRect(textFrame, withAttributes: textAttributes)
let waterMarkedImage = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
return waterMarkedImage
本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/shouji/article-123896-1.html
没发现一个有用的观点或论据
敢于鼓足勇气对美国说关你鸟事