CocoaPods trunk is moving to be read-only. Read more on the blog, there are 12 months to go.
| TestsTested | ✗ |
| LangLanguage | SwiftSwift |
| License | MIT |
| ReleasedLast Release | Dec 2016 |
| SwiftSwift Version | 3.0 |
| SPMSupports SPM | ✗ |
Maintained by Alexander Doloz, Alexander Doloz.
Freestyler lets you define styles for your application in a single place using declarative syntax, so you can easily change colors, fonts and other visual properties across all the app.
swift label <~ UILabel.style(textColor: UIColor.red) swift let redTextColor = UILabel.style(textColor: UIColor.red) swift [label1, label2] <~ redTextColor swift let greenTextColorAndBoldFont <~ UILabel.style(textColor: UIColor.green) <~ UILabel.style(font: UIFont.boldSystemFont(ofSize: 14.0)) /// or let greenTextColorAndBoldFont <~ [UILabel.style(textColor: UIColor.green), UILabel.style(font: UIFont.boldSystemFont(ofSize: 14.0))] /// or let greenTextColorAndBoldFont: Style = [UILabel.style(textColor: UIColor.green), UILabel.style(font: UIFont.boldSystemFont(ofSize: 14.0))] swift label <~ [redTextColor, greenTextColorAndBoldFont] // ^ label will be green and bold label <~ [greenTextColorAndBoldFont, redTextColor] // ^ label will be red; also bold though UIView to UILabel but not vice versa; in general, you can apply style of class to instance of subclass: swift label <~ UIView.style(backgroundColor: UIColor.yellow) // code below will crash 🔥 view <~ UILabel.style(textColor: UIColor.red) Using protocol Color, you can create palettes for often encountered colors in your app and give them meaningful name. It will also help to have a central place where all colors located so you can change them across all the app with one line of code:
enum Theme: Color {
case title
case subtitle
case background
var color: UIColor {
switch self {
case .title: return UIColor.black
case .subtitle: return UIColor.lightGray
case .background: return UIColor.white
}
}
}
// ... somewhere in code
label <~ UILabel.style(textColor: Theme.title)Also the same thing for fonts – Font protocol:
enum Typography: Font {
case big
case medium
case small
var font: Font {
switch self {
case .big: return UIFont.systemFont(ofSize: 18.0)
case .medium: return UIFont.systemFont(ofSize: 14.0)
case .small: return UIFont.systemFont(ofSize: 11.0)
}
}
}
// ... somewhere in code
label <~ UILabel.style(font: Typography.big)Freestyler folder to your project in Xcode; make sure Alexander Doloz, [email protected]
Freestyler is available under the MIT license. See the LICENSE.txt file for more info.