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函数的意思,求大神讲解下
Just check the function manual for this kind of problem
The content at the beginning of UI is from the
UIKit
library, which is the iOS control libraryUIKit
库 这是iOS控件库CG开头是来自
Core Graphic
The content at the beginning of CG is from theCore Graphic
library, which is 2D Drawing library