Spiffy 0.0.2

Spiffy 0.0.2

Balázs Hajagos维护。



Spiffy 0.0.2

  • 作者:
  • Balázs Hajagos

Spiffy

Build Status CocoaPods Reviewed by Hound

Spiffy是一个专为iOS应用开发的轻量级样式库,使用Swift编写。其主要目标是帮助定义易于应用的样式,而不是创建一个全能的包装器。

// Swift

import Spiffy
import UIKit

class ViewController: UIViewController {
	@IBOutlet weak var button: UIButton!
	@IBOutlet weak var label: UILabel!
	
	override func viewDidLoad() {
        super.viewDidLoad()
        
        button.styled(by: Styles.Showcase.Button.base)
        label.styled(by: Styles.Showcase.Label.base)
    }
}

extension Styles {
    fileprivate enum Showcase {
        enum Label {
            static let base = Styles.Label.Style(
                .alignment(.right),
                .color(.blue)
            )
        }
        
        enum Button {
            static let base: [Styling] = [
                Styles.View.Predefined.autolayouted,
                Styles.Button.Style(
                    .titleColor(with: .black, for: .normal),
                    .backgroundColor(with: .white, for: .normal),
                    .titleColor(with: .red, for: .highlighted),
                    .backgroundColor(with: .gray, for: .highlighted)
                )
            ]
        }
    }
}

要求

  • XCode 10.0
  • Swift 4.2

安装

CocoaPods

使用pod --version测试:1.6.1

# Podfile
use_frameworks!

target 'YOUR_TARGET_NAME' do
    pod 'Spiffy',    '~> 0.0.1'
end

替换YOUR_TARGET_NAME,然后在Podfile目录中键入

$ pod install