测试已测试 | ✗ |
语言语言 | SwiftSwift |
许可证 | MIT |
发布上次发布 | 2017 年 3 月 |
SwiftSwift 版本 | 3.0 |
SPM支持 SPM | ✗ |
由 Ivan Bruel 维护。
TextStyle
提供了在 iOS 中更轻松地管理动态字体大小。
使用 TextStyle
,您可以在 iOS 中支持动态字体大小,并通过辅助功能更改字体大小。
我们还提供对 NSNotificationCenter
观察者以及常用场景的 RxSwift
绑定的便捷包装。
public enum TextStyle {
case Title1
case Title2
case Headline
case Subheadline
case Body
case Caption1
case Caption2
case Footnote
case Callout
}
查看 Example
项目的示例,以更好地理解 TextStyle
的用法。
import TextStyle
class ViewController: UIViewController {
let label = UILabel()
private func viewDidLoad() {
super.viewDidLoad()
label.font = TextStyle.Body.font
TextStyle.observeFontChanged(self, selector: #selector(ViewController.fontChanged))
}
private func fontChanged() {
label.font = TextStyle.Body.font
}
deinit {
TextStyle.removeObserver(self)
}
}
import TextStyle
import RxSwift
class ViewController: UIViewController {
let label = UILabel()
let disposeBag = DisposeBag()
private func viewDidLoad() {
super.viewDidLoad()
TextStyle.Body.rx_font
.bindTo(label.rx_font)
.addDisposableTo(disposeBag)
}
}
iOS 9.3(包括模拟器)存在一个错误,它不会收到通知,请确保使用更新的 iOS 设备或 iOS 9.2 模拟器。
TextStyle 通过 CocoaPods 提供。要安装它,只需将以下行添加到您的 Podfile 中:
pod "TextStyle"
TextStyle 在 MIT 许可证下提供。有关更多信息,请参阅 LICENSE 文件。