Home > Back-end >  'UIEdgeInsetsEqualToEdgeInsets' is deprecated: Use == operator instead XCode 13
'UIEdgeInsetsEqualToEdgeInsets' is deprecated: Use == operator instead XCode 13

Time:04-05

Whenever i tried to run my code in XCode 13 getting warning and build failed

Warning message: 'UIEdgeInsetsEqualToEdgeInsets' is deprecated: Use == operator instead

extension UIButton {
    
   
    open override func point(inside point: CGPoint, with event: UIEvent?) -> Bool {
        if UIEdgeInsetsEqualToEdgeInsets(self.touchAreaEdgeInsets, .zero) || !self.isEnabled || self.isHidden { //Getting warning here
            return super.point(inside: point, with: event)
        }
        
        let relativeFrame = self.bounds
        let hitFrame = relativeFrame.inset(by: self.touchAreaEdgeInsets)
       // let hitFrame = UIEdgeInsetsInsetRect(relativeFrame, self.touchAreaEdgeInsets)
        
        return hitFrame.contains(point)
    }
   
}

CodePudding user response:

It's pretty obvious. You are going to check both parameters for equality. So just replace

if UIEdgeInsetsEqualToEdgeInsets(self.touchAreaEdgeInsets, .zero) 

with

if self.touchAreaEdgeInsets == .zero
  • Related