Looking at the docs for CGRect, the closest method insetBy:dx:dy:is that returns a new one CGRect. Therefore, the following code should work for you:
contentRect = contentRect.insetBy(dx: 0.0, dy: -(self.axis?.gridLineWidth ?? 0.0) / 2.0)
source
share