App crashes on call to setNeedsDisplay for custom button
问题 I've custom button, app crashes randomly on call to setNeedsDisplay . How to fix this crash? class MyVC: UIViewController { @IBOutlet weak var customButton: CustomButton! override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) { super.viewWillTransition(to: size, with: coordinator) self.customButton.setNeedsDisplay() // Random crash here } } class CustomButton: UIButton { // .... override func setNeedsDisplay() { self.imageEdgeInsets =