CocoaPods trunk is moving to be read-only. Read more on the blog, there are 18 months to go.
TestsTested | ✗ |
LangLanguage | SwiftSwift |
License | MIT |
ReleasedLast Release | Nov 2016 |
SwiftSwift Version | 3.0 |
SPMSupports SPM | ✗ |
Maintained by Alexander Doloz.
When we develop our applications from designer's mockups, we often encounter the same visual patterns over and over again – colors, fonts, etc. It's wise decision to keep them in one place in your app's code and reuse everywhere. That's exactly what FreestylerCore helps you to do.
FreestylerCore defines class Style
. Style can be applied to UIView
or UIBarButtonItem
. Multiple Style
s can be combined into one. See how to create your own styles and apply them in Usage section.
FreestylerCore is meant to be the part of the bigger framework – Freestyler. Freestyler = FreestylerCore + big bunch of styles. It's currently in active development and contributions are welcome.
Source
folder to your project in Xcode; make sure Here is basic usage; see more examples in Playground.
let roundCorners = Style("Round corners") {
(view: UIView) in
view.layer.cornerRadius = 5.0
}
let redBorder = Style("Red Border") {
(view: UIView) in
view.layer.borderColor = UIColor.red.CGColor
}
button <~ roundCorners <~ redBorder
// --- or ---
button <~ [roundCorners, redBorder]
// You can combine multiple styles into one
let style = roundCorners <~ redBorder
button <~ style
// You can apply style to multiple items at once
[button, label, imageView] <~ style
// And multiple styles to multiple labels too
[button, label, imageView] <~ [roundCorners, redBorder]
If you don't like using custom operators, there are corresponding methods:
button.apply(style: roundCorners).apply(style: redBorder)
// --- or ---
button.apply(styles: [roundCorners, redBorder])
// You can instantiate style from array literal
let style: Style = [roundCorners, redBorder]
button.apply(style: style)
// You can apply style to multiple items at once
[button, label, imageView].apply(style: style)
// And multiple styles to multiple labels too
[button, label, imageView].apply(styles: [roundCorners, redBorder])
Alexander Doloz, [email protected]
FreestylerCore is available under the MIT license. See the LICENSE.txt file for more info.