Selectors are used to designate to which controls a given rule set applies. Below you will find a list of selectors and combinators supported by Freestyle. Note that each entry is a link to its associated section in the CSS3 specification. Simply click the entry to find detailed information about the given selector or combinator.
Simple selectors allow for the selection of controls by name
, class
, and id
. A selector may include further restrictions on a selected element via attribute expressions; Freestyle does not currently support those. Below is a list of simple selectors supported in Freestyle.
Below is a sample of each of the simple selectors.
/* element type selector */
button {}
/* universal selector */
* {}
/* class selector */
.my-class {}
/* id selector */
#my-id {}
See the Cascading Style Sheets Overview section to learn how to specify the the id
and class
elements for a control.
NOTE: Pseudo-elements will parse but they are not implemented.
Attribute selectors allow for controls to be selected based on the content of their attributes. Objective-c classes do not have attributes, per se, but these can be thought of as objective-c properties, in simple cases. Internally, Freestyle will use Key-value Coding (KVC) to look up a property name. If that lookup is successful, then one of the following tests is performed, returning true only if the match is successful.
Many of the controls in UIKit allow settings to be associated with specific states: normal
, highlighted
, disabled
, etc. Freestyle uses pseudo-classes to indicate to which state a given rule set should apply.
Below is a sample of some pseudo-classes in use.
/* normal button state */
button:normal {}
/* highlighted button state */
button:highlighted {}
Pseudo-classes representing control states are currently limited to the last selector in a selector sequence.
Pseudo-classes are also used to match controls that meet a certain criteria. For example, it is possible to indicate that a control can match only if it is the first child of its parent, or the last child, etc. Freestyle supports the following pseudo-classes in this category:
Combinators allow the expression of complex relationships between controls. A combinator combines any combination of simple selectors and other combinators. Each combinator represents a tree relationship that must be met to select a target control.
Below is a sample of each of these combinators.
/* descendant combinator */
view button {}
/* child combinator */
view > label {}
/* adjacent sibling combinator */
button + label
/* general sibling combinator */
button ~ label