CostumeKit
1.0.0
主题应用程序的基本类型。
Costumekit由一组Swift协议组成。它们本来应该在您的应用程序中实现。
可可叮咬的小叮咬#270:用costumekit实施主题
包括Color和ColorPalette协议。
用法:
public enum MyAppColors : Color , ColorPalette {
case white = " FFFFFF "
case lightTeal = " 3CB39E "
case forestGreen = " 216055 "
case black = " 000000 "
} 包括Font协议和iOS系统字体的一个混凝土SystemFont实现。
用法:
public struct MyAppFont : Font {
public init ( size : FontSize = . textStyle ( . body ) ) {
self . size = size
}
// Font
public var size : FontSize
// FontConvertible
public var FontValue : UIFont {
return UIFont ( name : " SomeCustomFont " , size : pointSize ) !
}
} 包括SVG协议和SVGMetadata类型。
用法:
enum MyAppSVGs {
case clockGlyph
case bird
}
extension MyAppSVGs : SVG {
public func metadata ( ) -> SVGMetadata {
switch self {
case . clockGlyph : return SVGMetadata ( name : " clock " , size : CGSize ( width : 100 , height : 100 ) , fullColor : false )
case . bird : return SVGMetadata ( name : " bird " , size : CGSize ( width : 58 , height : 28 ) , fullColor : true )
}
}
}您对SVGMetadata的作用取决于您。我推荐Michael Choe的Swiftsvg。在此处阅读更多信息,以了解如何使用它。
Costumekit的目标是成为一个通用的解决方案,因此没有假设应该从磁盘,解析等方面检索某些东西。
包括Costume方案。用法:
open class MyAppCostume : Costume {
let spacing = CGFloat ( 8 )
public func wearRootBackground ( _ view : UIView ) {
view . backgroundColor = Color . black . colorValue
}
public func wearHeadline ( _ label : UILabel ) {
label . font = MyAppFont ( size : . textStyle ( . title1 ) ) . fontValue
label . textColor = MyAppColors . forestGreen . colorValue
}
public var name : String { return " Default " }
public var description : String { return " The default costume. " }
public init ( ) { }
}干杯。