Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I made the mistake up updating my project to Swift 4.2 without waiting for pods to be updated. I have slowly updated all of my code, but there's one line that I can't seem to figure out.

var animationRect = UIEdgeInsetsInsetRect(frame, UIEdgeInsets(top: padding, left: padding, bottom: padding, right: padding)) 

The error I receive is,

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

Any help with this would be greatly appreciated!

like image 262
Dustin Johnson Avatar asked Jul 31 '18 14:07

Dustin Johnson


1 Answers

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) 
like image 168
Leo Dabus Avatar answered Oct 05 '22 07:10

Leo Dabus