UIEdgeInsetsInsetRect' has been replaced by instance method 'CGRect.inset(by:) UIEdgeInsetsInsetRect' has been replaced by instance method 'CGRect.inset(by:) swift swift

UIEdgeInsetsInsetRect' has been replaced by instance method 'CGRect.inset(by:)


The error it is pretty self explanatory. You can use it like this:

var animationRect = frame.inset(by: UIEdgeInsets(top: padding, left: padding, bottom: padding, right: padding))

or simply

var animationRect = frame.insetBy(dx: padding, dy: padding)


Swift 4.2 and Xcode 10

Earlier it was like this -

let bounds = UIEdgeInsetsEqualToEdgeInsets(view.bounds,view.safeAreaInsets)

Now for swift 4.2 -

let bounds = view.bounds.inset(by: view.safeAreaInsets)


UIEdgeInsets in Swift 4.2

Earlier version

let padding = UIEdgeInsets(top: 0, left: 40, bottom: 0, right: 5) override func textRect(forBounds bounds: CGRect) -> CGRect {            return UIEdgeInsetsInsetRect(bounds, padding)        }
to swift 4.2 and Xcode 10
let padding = UIEdgeInsets(top: 0, left: 40, bottom: 0, right: 5) override func textRect(forBounds bounds: CGRect) -> CGRect {        return rect.inset(by: GlobalClass.language == "ar" ? paddingR : padding)    }