Is there a way we can make our IBInspectable
properties feature Size Classes in Interface Builder? (Similar to Font)
Clicking the '+' sign would allow you to choose a different font (size and other properties) for a different size class.
I'm asking because I created a custom view which features a width property and I want to make that width different on some size classes.
Storyboards in Interface Builder by default use size classes. Size classes are traits assigned to user interface elements, like scenes or views. They provide a rough indication of the element's size. Interface Builder lets you customize many of your layout's features based on the current size class.
In easy way we can say Autolayout is used for displaying same layout comatible on different different iPhone/iPad screen sizes (ex. Keep button in center for all screen sizes) while through Autoresizing classes we can set a different layout for a particular screen size.
I'm afraid there is no option for IBInspectable properties yet, but you definitely can respond to size class changes via UITraitEnvironment protocol and UIContentContainer protocol that already implemented by UIView and UIViewController (see WWDC 2014, Building Adaptive Apps with UIKit to see more about trait collections and trait environment). The font property seems get handled by Xcode just like the constraints or installed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With