基于主题的Swift开发基础工具包
包含颜色、字体、布局等,可配置可缓存
- App 的样式参数(颜色、字体、布局)存储于 json 文件中。
- 可由用户修改主题参数并保存或者分享。
- 便捷的方式获取屏幕布局参数、如各边安全区域尺寸,便于机型适配。
pod 'Inspire'
pod install
在 Package.swift 中声明依赖项:
.package(url: "https://github.com/xaoxuu/Inspire.git", from: "1.1.0"),
view.backgroundColor = .background
view.tintColor = .accent
let lb = UILabel()
lb.font = .regular(15)
lb.font = .bold(20, for: .title)
lb.font = .regular(14, for: .code)
let topMargin = layout.topBarHeight(for: self)
let bottomMargin = layout.bottomBarHeight(for: self)
let safeArea = layout.safeAreaInsets(for: self)
let safeArea2 = Inspire.shared.screen.safeAreaInsets
let layout = Inspire.shared.layout
view.frame.size.height = layout.rowHeight
view.layer.cornerRadius = layout.cornerRadius.large
// 保存
Inspire.shared.cache()
Inspire.shared.cache(named: "myTheme")
// 读取
let ipr = Inspire.init("myTheme")