CocoaPods trunk is moving to be read-only. Read more on the blog, there are 2 months to go.
| TestsTested | ✗ |
| LangLanguage | SwiftSwift |
| License | MIT |
| ReleasedLast Release | Jan 2017 |
| SwiftSwift Version | 3.0 |
| SPMSupports SPM | ✗ |
Maintained by Sam Easterby-Smith.
DynamicStyles, the missing stylesheet manager for iOS apps.
Clone the repository if you want to integrate the framework manually or play with the example project.
Create a property list called Stylesheet.plist somwehere in your project. There is one in the example project in the repo which you could use as a starting point. See the syntax section below for details.
You can theoretically tell it to use a custom named plist from code but you won’t get IB rendering if you do that.
DynamicStyleLabel. The module should update by itself (if it doesn’t, make sure it says DynamicStyles)Style Name – type the name of one of your defined styles in there and watch the label update!The same goes for buttons. The custom class for them is DynamicStyleButton. Plan is to extend this to other UIView variants sometime.
label.styleName="heading"
or in a more verbose way…
let stylesheet = Stylesheet.defaultStylesheet
let headingStyle = stylesheet.style("heading")
label.style=headingStyle
The Stylesheet.plist should contain a dictionary of style definitions. Each definition is a dictionary with the name of the style as the key.
Definitions may use the following keys:
| key | type | default | notes |
|---|---|---|---|
| family | string | Helvetica Neue | |
| face | string | Regular | |
| size | number | 17 | |
| shouldScale | boolean | NO | Enables dynamic type scaling (including larger accessibility sizes) |
| parent | string | reference to a parent style name - must not be circular | |
| paragraphSpacing | number | 0 | the spacing between paragraphs in points |
| lineSpacing | number | 0 | the spacing between consecutive lines of text in points |
| alignment | string | left | can be left, center, right, justified or natural |
| minimumLineHeight | number | nil | |
| maximumLineHeight | number | nil |
… so an example might look a bit like this
* root
* baseStyle
* family : Courier
* headlineStyle
* face : Bold
* size : 24
* parent : baseStyle
* bigHeadlineStyle
* size : 48
* parent : headlineStyle
* bodyStyle
* shouldScale : true
* parent : baseStyle
* paragraphSpacing : 5