You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
StyleKit is a microframework that enables you to style your applications using a simple JSON file. Behind the scenes, StyleKit uses [UIAppearance](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIAppearance_Protocol/) and some selector magic to apply the styles. You can also customize the parser for greater flexibility.
6
6
7
7
8
-
###How does it work?
8
+
###How does it work?
9
9
10
-
####Create a JSON file in the following format
10
+
####Create a JSON file in the following format
11
11
12
12
```js
13
13
{
14
+
"@headingFont":"HelveticaNeue-Bold:30.0",
14
15
"UILabel": {
15
-
"font":"HelveticaNeue-Bold:30.0",
16
+
"font":"@headingFont",
16
17
"backgroundColor":"#000FFF"
17
18
},
18
19
"StyleKitDemo.SKView": {
@@ -30,7 +31,7 @@ StyleKit is a microframework that enables you to style your applications using a
30
31
"StyleKitDemo.SKNavigationBar": {
31
32
"titleTextAttributes": {
32
33
"NSColor":"#000FFF",
33
-
"NSFont":"HelveticaNeue-Bold:30.0"
34
+
"NSFont":"@headingFont"
34
35
}
35
36
},
36
37
"StyleKitDemo.SKTextField": {
@@ -39,7 +40,7 @@ StyleKit is a microframework that enables you to style your applications using a
On application launch the JSON file will be loaded and the styles applied.
59
60
60
61
61
-
###The JSON file structure
62
+
###The JSON file structure
62
63
63
64
Each object inside the JSON file should contain the name of the UIView as a key and the object inside should either contain the properties/functions that need to be set/called or another UIView, this will give you the ability to apply styles on views when contained in other views, an example of this would be the following.
64
65
@@ -79,7 +80,25 @@ This would apply HelveticaNeue-Bold with size 20 to all the UIButtons except the
79
80
80
81
Custom classes must be namespaced by the name of the module they are contained in. e.g. `StyleKitDemo.SKTextField`
81
82
82
-
###Bring Your Own Parser
83
+
### Aliases
84
+
85
+
```js
86
+
{
87
+
"@mainFont":"HelveticaNeue-Bold:20.0",
88
+
"@primaryColor":"#000FFF",
89
+
"UIButton": {
90
+
"font":"@mainFont"
91
+
},
92
+
"MyApp.LoginView": {
93
+
"UIButton": {
94
+
"font":"HelveticaNeue-Light:25.0",
95
+
"titleColor:normal":"@primaryColor"
96
+
}
97
+
}
98
+
}
99
+
```
100
+
101
+
### Bring Your Own Parser
83
102
84
103
StyleKit's initialiser supports passing a custom parser which should conform to the `StyleParsable` protocol.
0 commit comments