'UIEdgeInsetsEqualToEdgeInsets'已弃用:使用 == 运算符代替 XCode 13



每当我试图在XCode 13中运行代码时,都会收到警告并构建失败的

警告消息:"UIEdgeInsetsEqualToEdgeInsets"已弃用:请改用==运算符

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

相关内容

  • 没有找到相关文章

最新更新