TestsTested | ✗ |
LangLanguage | SwiftSwift |
License | MIT |
ReleasedLast Release | Mar 2017 |
SwiftSwift Version | 3.0 |
SPMSupports SPM | ✗ |
Maintained by Ivan Bruel.
TextStyle
provides easier management of dynamic font sizing in iOS.
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.
public enum TextStyle {
case Title1
case Title2
case Headline
case Subheadline
case Body
case Caption1
case Caption2
case Footnote
case Callout
}
Check the Example
project for a better understanding of how TextStyle
works.
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 (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.
TextStyle is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "TextStyle"
TextStyle is available under the MIT license. See the LICENSE file for more info.