我想将此行转换为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))
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。