Swift 3.0转换错误修复

时间:2016-09-26 03:07:02

标签: core-graphics swift3 cgrect

我有一个快速的2.2项目。 现在我将它升级到Swift 3.0但我有一些错误。

open var gridClippingRect: CGRect
{
    var contentRect = viewPortHandler?.contentRect ?? CGRect.zero
    contentRect.insetInPlace(dx: 0.0, dy: -(self.axis?.gridLineWidth ?? 0.0) / 2.0)
    return contentRect
}

错误:类型的值' CGRect'没有会员' insetInPlace'

如何解决此错误?

1 个答案:

答案 0 :(得分:9)

查看CGRect的文档,最接近的方法是insetBy:dx:dy:,它返回一个新的CGRect。因此,以下代码应该适合您:

contentRect = contentRect.insetBy(dx: 0.0, dy: -(self.axis?.gridLineWidth ?? 0.0) / 2.0)