Custom Views
How to use Classy with your own custom UIView subclasses
How to use Classy with your own custom UIView subclasses
Imagine we are building a control called MYCircularSlider which will behave like a UISlider but will render in a circular/dial shape. We want the control to be highly configurable as its used throughout the app in different border styles, colors, radius etc.
This is what MYCircularSlider.h
looks like
When classy encounters MYCircularSlider for the first time it will use reflection to determine the types of MYCircularSlider's properties. So without doing any configuration you can style most of the properties
MYCircularSlider {
track-tint-color blue
fill-color #CCDE73
track-radius 40
thumb-insets 2, 4, 2, 4
}
Unfortunately the Objective-C runtime doesn't give us back enough information to configure enums and selectors automatically. In these cases you can manually tell Classy what todo.
Configuration code should be placed before setting the [CASStyler defaultStyler].filePath
.
See the getting started section.
To configure the MYBorderStyle property trackBorderStyle
To configure the selector setThumbTintColor:forState:
Now we can style MYCircularSlider completely
MYCircularSlider {
track-tint-color blue
fill-color #CCDE73
track-radius 40
thumb-insets 2, 4, 2, 4
track-border-style bezel
thumb-tint-color white
thumb-tint-color[state:highlighted] green
thumb-tint-color[state:disabled] #999
}