Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 855
chrisamanse Avatar asked Jun 02 '15 07:06

chrisamanse


People also ask

What is size classes and how can we use it?

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.

What is Autolayout What is size classes and how can we use it?

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.


Video Answer


1 Answers

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.

like image 150
Sega-Zero Avatar answered Oct 02 '22 15:10

Sega-Zero