CostumeKit
1.0.0
ประเภทพื้นฐานสำหรับพวกเขาแอพ
CostumeKit ทำจากชุดโปรโตคอล Swift พวกเขาตั้งใจจะนำไปใช้ในแอพของคุณ
ให้ความสำคัญกับ Cocoa Bite เล็ก ๆ น้อย ๆ #270: การใช้งานธีมกับ CostumeKit
รวมถึงโปรโตคอล Color และ ColorPalette
การใช้งาน:
public enum MyAppColors : Color , ColorPalette {
case white = " FFFFFF "
case lightTeal = " 3CB39E "
case forestGreen = " 216055 "
case black = " 000000 "
} รวมโปรโตคอล Font และการใช้งาน SystemFont คอนกรีตหนึ่งรายการสำหรับแบบอักษร iOS ระบบ
การใช้งาน:
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 ขึ้นอยู่กับคุณ ฉันแนะนำ SwiftSVG จาก Michael Choe อ่านเพิ่มเติมที่นี่เพื่อเรียนรู้วิธีการใช้งาน
เป้าหมายของ 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 ( ) { }
}ไชโย