TextStyle 1.4.2

TextStyle 1.4.2

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Mar 2017
SwiftSwift Version 3.0
SPMSupports SPM

Maintained by Ivan Bruel.



TextStyle 1.4.2

TextStyle

TextStyle provides easier management of dynamic font sizing in iOS.

Image

Benefits

With TextStyle you can support Dynamic Font Sizing in iOS, allowing font size changes through accessibility.

We also provide convenient wrappers for the NSNotificationCenter observer and also RxSwift bindings for common usage.

Available TextStyles

public enum TextStyle {

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

Usage

Check the Example project for a better understanding of how TextStyle works.

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

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

Reminder

iOS 9.3 (which includes the simulator) has a bug in which it doesn’t receive the notification, be sure to use either an update iOS device or the iOS 9.2 simulator.

Installation

TextStyle is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "TextStyle"

License

TextStyle is available under the MIT license. See the LICENSE file for more info.