StyleStrategy
public protocol StyleStrategy
Conform to style strategy to define how your UI controls should retrieve their style sets.
-
Defines how to retrieve a StyleSet using a styleKey. i.e. retrieve from plist, json, user defaults, programmatic definition. Source of style sets could be included at compile time or downloaded at run time, or updated dynamically throughout lifecycle of app.
Declaration
Swift
static func retrieveStyleSet(forStyleKey styleKey: StyleKeyProtocol) -> StyleSet?
-
transformDictionaryOfPropertiesIntoStyleSet(properties:ColorSetType:FontSetType:customTransformation:)
Extension methodUseful function for transforming a dictionary into a StyleSet. Use this function for values that must be transformed from an abstract representation into its meaningful value. i.e. transforming a color key as a String into a UIColor
Declaration
Swift
public static func transformDictionaryOfPropertiesIntoStyleSet(properties: [String: Any], ColorSetType: ColorSetProtocol.Type? = nil, FontSetType: FontSetProtocol.Type? = nil, customTransformation: ((Any) -> Any?)? = nil) -> StyleSet
Parameters
properties
[String: Any] containing all property keys -> values
ColorSetType
Optional. If set contains any colors that need to be transformed from String -> UIColor, use a type implementing ColorSetProtocol to perform the conversion
FontSetType
Optional. If set contains any fonts that need to be transformed from String -> UIFont, use a type implementing FontSetProtocol to perform the conversion
customTransformation
Optional. Performs custom logic for transforming dictionary’s value into a value consumable by the StyleSet
Return Value
A style set converted from dictionary