TextStyle 版本 1.4.2

TextStyle 版本 1.4.2

测试已测试
语言语言 SwiftSwift
许可证 MIT
发布上次发布2017 年 3 月
SwiftSwift 版本3.0
SPM支持 SPM

Ivan Bruel 维护。



TextStyle 版本 1.4.2

TextStyle

TextStyle 提供了在 iOS 中更轻松地管理动态字体大小。

Image

优势

使用 TextStyle,您可以在 iOS 中支持动态字体大小,并通过辅助功能更改字体大小。

我们还提供对 NSNotificationCenter 观察者以及常用场景的 RxSwift 绑定的便捷包装。

可用的 TextStyle

public enum TextStyle {

  case Title1
  case Title2
  case Headline
  case Subheadline
  case Body
  case Caption1
  case Caption2
  case Footnote
  case Callout
}

用法

查看 Example 项目的示例,以更好地理解 TextStyle 的用法。

不使用 RxSwift

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)
  }
}

使用 RxSwift

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 文件。