It will crash at line 5, because the constraint become nil after NSLayoutConstraint.deactivate.The above code worked fine until iOS 12.As I understand it, NSLayoutConstraint.deactivate is supposed to have the same role as "constraint.isActive = nil" but the reference count of constraint is reduced and it is released.I asked here to see if their behavior changed in iOS 13.There are two solutions I think.1. remove weak word at line 22. remove line 4 and 6.