A Powerful , Extensible CSS Parser written in pure Swift.
Basic Usage
From CSS:
To Cocoa:
It's very easy to setup and parse CSS with SwiftCssParser
:
Extension
It's very easy to build your own Powerful, Flexiable CSS based solutions base on SwiftCssParser
.
Example1: SwiftDeviceCss
In most cases, Auto Layout
can help us calculates the size and location of our views. But in some cases, we need to set specifc size and location for our views based on device type (device's screen size) to accomplish the Pixel Perfect
design.
So, we can use SwiftCssParser
to get layout value from CSS file. Different Device has different configuration file.
Then just layout:
Exeample2: SwiftCssTheme
We can also create a powerful theme manager base on SwiftCssParser
.
For example, we want to create a night & day theme.
If we want to be able to dynamically modify the background color of UIView:
Then, we just need to specify the background color's CSS selector and key:
Changing theme is even easier:
All the code and demo can be found in the project. Feel free to download and experiment. Advice and pull requests are welcome.
Installation
CocoaPods:
pod 'SwiftCssParser'
License
SwiftCssParser
is under the MIT license.