func coloredImage(image: UIImage, red: CGFloat, green: CGFloat, blue: CGFloat, alpha: CGFloat) -> UIImage! {
let rect = CGRect(origin: CGPointZero, size: image.size)
UIGraphicsBeginImageContextWithOptions(image.size, false, image.scale)
let context = UIGraphicsGetCurrentContext()
image.drawInRect(rect)
CGContextSetRGBFillColor(context, red, green, blue, alpha)
CGContextSetBlendMode(context, CGBlendMode.SourceAtop)
CGContextFillRect(context, rect)
let result = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
return result
}
主要是不太明白这些UI和CG函数的意思,求大神讲解下
迷茫2017-04-17 17:36:29
這種問題自己查函數手冊就好了
UI開頭的內容是來自UIKit
庫這是iOS控制項庫UIKit
库 这是iOS控件库
CG开头是来自 Core Graphic
CG開頭是來自Core Graphic
庫這是2D繪圖庫