'UIEdgeInsetsEqualToEdgeInsets' 已弃用:改用 == 运算符 XCode 13

'UIEdgeInsetsEqualToEdgeInsets' is deprecated: Use == operator instead XCode 13

每当我尝试 运行 我的代码 XCode 13 收到警告并构建失败

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)
    }
   
}

这很明显。您将检查两个参数是否相等。所以只需替换

if UIEdgeInsetsEqualToEdgeInsets(self.touchAreaEdgeInsets, .zero) 

if self.touchAreaEdgeInsets == .zero