TweaKit
,也称为 "Tweak It",是一个纯 Swift 库,用于调整参数和功能标记。
pod 'TweaKit', '~> 1.0'
github "Alpensegler/TweaKit" ~> 1.0
.package(url: "https://github.com/Alpensegler/TweaKit.git", .upToNextMajor(from: "1.0.0"))
import TweaKit
enum Tweaks {
@Tweak<CGFloat>(name: "Line Width", defaultValue: 1, from: 0.5, to: 2, stride: 0.05)
static var sketchLineWidth
@Tweak(name: "Line Color", defaultValue: UIColor(red: 0.227, green: 0.529, blue: 0.992, alpha: 1))
static var sketchLineColor
@Tweak(name: "Order", defaultValue: SketchAction.allCases)
static var sketchActionsOrder
@Tweak(name: "Name", defaultValue: "My Sketch")
static var sketchName
@Tweak(name: "Navigation Title", defaultValue: "Demo", options: ["Demo", "Example", "Guide"])
static var rootViewNavigationTitle
@Tweak(name: "Shake To Show Tweaks", defaultValue: true)
static var rootViewEnableShake
static let context = TweakContext {
TweakList("Sketch") {
TweakSection("Line") {
$sketchLineWidth
$sketchLineColor
}
TweakSection("Info") {
$sketchName
}
TweakSection("Actions") {
$sketchActionsOrder
}
}
TweakList("Root View") {
TweakSection("UI") {
$rootViewNavigationTitle
}
TweakSection("Interaction") {
$rootViewEnableShake
}
}
}
}
您可以调整以下类型
Bool
Int[8|16|32|64]
, UInt[8|16|32|64]
, Float
, Double
和 CGFloat
String
Array
,其中 Element
符合某些协议UIColor
除了直接更改值之外,您还可以从给定的选项中选择值。
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
_ = Tweaks.context
return true
}
您可以随时初始化调整上下文,但应确保在使用调整项之前初始化上下文。
myViewController.title = Tweaks.rootViewNavigationTitle
mySketchView.lineWidth = Tweaks.sketchLineWidth
Tweaks.context.show()
就是这样。现在您已经对 TweaKit
有了足够的了解。
请随意试用演示应用程序或查看 wiki 和 documentation 以获取更多使用信息。
TweaKit
的 Logo 是一只可爱的小鼬,一种可以在夏季和冬季调整皮毛颜色的鼬科动物。