首页  >  问答  >  正文

ios - Swift 函数代码求讲解每句的意思

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函数的意思,求大神讲解下

PHP中文网PHP中文网2741 天前394

全部回复(2)我来回复

  • PHP中文网

    PHP中文网2017-04-17 17:36:29

    雷雷


    回复
    0
  • 迷茫

    迷茫2017-04-17 17:36:29

    这种问题 自己查函数手册就好了
    UI开头的内容是 来自UIKit库 这是iOS控件库UIKit库 这是iOS控件库
    CG开头是来自 Core GraphicCG开头是来自 Core Graphic库 这是2D绘图库

    回复
    0
  • 取消回复