The style dictionary maps property names to their corresponding values. The values are supplied as parameters to the selectors that the property names get converted into. The framework does not assume that a property name needs ‘set’ prepended to it in order to create a selector, but it will prepend ‘set’ if the property name itself is not a valid selector on the target object. Multiple parameters can be passed to selectors using the JSON array syntax. Only selectors whose parameters are supported by the styling framework’s @type syntax can be called. The following examples show how one can call single-parameter and multiple-parameter selectors.

Single parameter

"textColor" : "@resource:blackColor"

Multiple parameters

"titleColor:forState" : ["@resource:whiteColor", "@resource:UIControlStateNormal"]
Sub-Properties

Sub-properties are also supported, as shown in the following code example. There is no limit to the level of sub-properties, but if you are calling a property five levels deep it probably does not make sense, could be error prone, and would be hard to debug. This feature is primarily useful for accessing a sub-property one level deep; the best example is the CALayer object’s properties, which are sub-properties accessed through the layer property of a UIView.

"layer.borderColor" : "@colorref:@resource:blueColor"
Comments

JSON does not support comments, but the theme JSON does support C-style comments since they can be very useful in a large file with many styles. Comments are stripped out of the file before the JSON is parsed, so the theme JSON becomes valid JSON before it reaches the parser.


Copyright © 1997, 2014 Oracle and/or its affiliates. All rights reserved. Legal Notices