I actually updated the extension below (found here: Size class specifically for portrait 3.5 inch (iPhone 4S) XCode 6? ) for Swift 5.0, and it works except when the constraint being modified has a "vary for traits" property and I cannot figure out why?
extension NSLayoutConstraint
{
//We use a simple inspectable to allow us to set a value for iphoneSE / 5s.
@IBInspectable var iPhoneSE_PortraitConstant: CGFloat
{
set{
//Only apply value to iphone SE and 5s devices.
if (UIScreen.main.bounds.size.height < 660 && UIScreen.main.bounds.size.width < 330)
{
self.constant = newValue;
}
}
get
{
return self.constant;
}
}
}
I'm guessing that Xcode is first finding the constraint and them seeing if it has a Vary for Traits addition and for this reason ignores the extension? How can I get past this?