Swiftpack.co -  xaoxuu/Inspire as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
xaoxuu/Inspire
主题式Swift开发工具包,包含布局、颜色、字体等。
.package(url: "https://github.com/xaoxuu/Inspire.git", from: "2.1.0")

Inspire

基于主题的Swift开发工具包

包含颜色、字体、布局等,可配置可缓存

特性

可缓存的

  • App 的样式参数(颜色、字体、布局)存储于 json 文件中。

可配置的

  • 可由用户修改主题参数并保存或者分享。

提供便利

  • 便捷的方式获取屏幕布局参数、如各边安全区域尺寸,便于机型适配。

开始使用

使用 CocoaPods

pod 'Inspire'
pod install

使用 Package.swift

在 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")

GitHub

link
Stars: 15
Last commit: 2 weeks ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API