微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

StyleKit 可配置 UI Style 工具库

程序名称:StyleKit

授权协议: MIT

操作系统: OS X

开发语言: Swift

StyleKit 介绍

StyleKit 是能让你使用一个简单的 JSON 文件美化你的应用的微框架。

它如何工作?

按如下格式创建一个 JSON 文件

{
    "UILabel": {
        "font": "HelveticaNeue-Bold:30.0",
        "backgroundColor": "#000FFF"
    },
    "StyleKitDemo.SKView": {
        "StyleKitDemo.SKLabel": {
            "font": "HelveticaNeue-Bold:20.0",
            "backgroundColor": "#FFF000",
            "color": "#fff"
        },
        "StyleKitDemo.SKButton": {
            "font": "HelveticaNeue-Light:20.0",
            "titleColor:normal": "#FFFFFF",
            "titleColor:highlighted": "#000000"
        }
    },
    "StyleKitDemo.SKNavigationBar": {
        "titleTextAttributes": {
            "NSColor": "#000FFF",
            "NSFont": "HelveticaNeue-Bold:30.0"
        }
    },
    "StyleKitDemo.SKTextField": {
        "font": "HelveticaNeue-Light:20.0",
        "textColor": "#000FFF"
    }
}

加载 JSON 文件

func application(application: UIApplication,
                 didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
    if let styleFile = NSBundle.mainBundle().URLForResource("style", withExtension: "json") {
        StyleKit(fileUrl: styleFile)?.apply()
    }
    return true
}

安装:

Carthage

github "146BC/StyleKit" ~> 0.3

CocoaPods

Add the 146BC Source

source 'https://github.com/146BC/Specs.git'
source 'https://github.com/CocoaPods/Specs.git'


pod 'StyleKit', '~> 0.3

StyleKit 官网

https://github.com/146BC/StyleKit

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐