Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added titleFont var to set another font in title label #141

Merged
merged 2 commits into from
May 23, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Master
------

* Added `titleFont` as open var to set another font in `titleLabel` [#141](https://github.com/Skyscanner/SkyFloatingLabelTextField/pull/141). Thanks to [@rabenson](https://github.com/rabenson) and [@rubenadlm](https://github.com/rubenadlm).

v3.1.0
------

Expand Down
12 changes: 10 additions & 2 deletions Sources/SkyFloatingLabelTextField.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ open class SkyFloatingLabelTextField: UITextField { // swiftlint:disable:this ty
}
}

/// A UIColor value that determines text color of the placeholder label
/// A UIFont value that determines text color of the placeholder label
dynamic open var placeholderFont: UIFont? {
didSet {
updatePlaceholder()
Expand All @@ -82,6 +82,13 @@ open class SkyFloatingLabelTextField: UITextField { // swiftlint:disable:this ty
}
}

/// A UIFont value that determines the text font of the title label
dynamic open var titleFont: UIFont = .systemFont(ofSize: 13) {
didSet {
updateTitleLabel()
}
}

/// A UIColor value that determines the text color of the title label when in the normal state
@IBInspectable dynamic open var titleColor: UIColor = .gray {
didSet {
Expand Down Expand Up @@ -292,7 +299,7 @@ open class SkyFloatingLabelTextField: UITextField { // swiftlint:disable:this ty
fileprivate func createTitleLabel() {
let titleLabel = UILabel()
titleLabel.autoresizingMask = [.flexibleWidth, .flexibleHeight]
titleLabel.font = .systemFont(ofSize: 13)
titleLabel.font = titleFont
titleLabel.alpha = 0.0
titleLabel.textColor = titleColor

Expand Down Expand Up @@ -413,6 +420,7 @@ open class SkyFloatingLabelTextField: UITextField { // swiftlint:disable:this ty
}
}
titleLabel.text = titleText
titleLabel.font = titleFont

updateTitleVisibility(animated)
}
Expand Down