IBDesignables and traitCollection in live rendering
问题 I am building my custom UIControl, a custom button built as an IBDesignable, which needs to change based on the size class in which it is being displayed. I have a method -setupForTraitCollection, which looks like this: func setupForTraitCollection() { switch(traitCollection.horizontalSizeClass, traitCollection.verticalSizeClass) { case (.Regular, _): // iPad - not compressed design compressed = false default: // iPhone - compressed design compressed = true } } This code works great when