Sorry for the novice question.
But just as the title says, I can't seem to use these functions in Swift 3. I have tried by importing the CoreGraphics library, but to no avail.
Does anyone know why?
Thanks in advance.
The functions are working fine, but their names have changed (a bit):
let frame = CGRect.zero
let x = frame.integral
frame.insetBy(dx: 0, dy: 0)
import CoreGraphics
let rect = CGRect()
let rectIntegral = rect.integral
Thanks:)
Actually you don't need to import CoreGraphics.
In Swift 3 Objective-C function
CGRect CGRectIntegral(CGRect rect)
has become
var integral: CGRect { get }
and
CGRect CGRectInset(CGRect rect, CGFloat dx, CGFloat dy);
has become
func insetBy(dx: CGFloat, dy: CGFloat) -> CGRect
Both API have to be called on the CGRect
instance for example
let newFrame = view.frame.insetBy(dx: 10.0, dy:10.0)
A hint to find out yourself
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With