chrisamanse
chrisamanse

Reputation: 4319

Using Size Classes in IBInspectable properties

Is there a way we can make our IBInspectable properties feature Size Classes in Interface Builder? (Similar to Font)

enter image description here

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.

Upvotes: 17

Views: 1866

Answers (1)

Sega-Zero
Sega-Zero

Reputation: 3017

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.

Upvotes: 8

Related Questions