核心图形 – Swift 3和CGContextDrawImage
发布时间:2020-12-14 05:45:03 所属栏目:百科 来源:网络整理
导读:我想将此行转换为Swift 3当前语法代码,但似乎存在一些问题: CGContextDrawImage(context,CGRect(x:0.0,y: 0.0,width: image!.size.width,height: image!.size.height),image!.cgImage) 根据CoreGraphics.apinotes CGContextDrawImage转换为CGContext.draw:
我想将此行转换为Swift 3当前语法代码,但似乎存在一些问题:
CGContextDrawImage(context,CGRect(x:0.0,y: 0.0,width: image!.size.width,height: image!.size.height),image!.cgImage) 根据CoreGraphics.apinotes CGContextDrawImage转换为CGContext.draw: Name: CGContextDrawImage # replaced by draw(_ image: CGImage,in rect: CGRect,byTiling: Bool = false) SwiftName: CGContext.__draw(self:in:image:) SwiftPrivate: true 当我尝试做: CGContext.draw(context as! CGImage,in: CGRect(x:0.0,y:0.0,byTiling: false) 似乎有一些简单的语法干扰编译器,但我看不到(实际上我收到一个典型的模糊错误): 任何人都可以帮助我使用这个新的swift 3语法代码吗?
您需要将其称为CGContext的实例方法:
context.draw(image!.cgImage!,in: CGRect(x: 0.0,height: image!.size.height)) 检查the latest reference of (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |