From a8303908c7eda89d04f0008a3c23feb7c023dfc8 Mon Sep 17 00:00:00 2001 From: DamienBallenghien Date: Thu, 5 Jul 2018 16:33:57 +0200 Subject: [PATCH 1/2] Add placeholderFont handling --- AnimatedTextInput/Classes/AnimatedTextInput.swift | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/AnimatedTextInput/Classes/AnimatedTextInput.swift b/AnimatedTextInput/Classes/AnimatedTextInput.swift index a6b74ca..b4e2659 100755 --- a/AnimatedTextInput/Classes/AnimatedTextInput.swift +++ b/AnimatedTextInput/Classes/AnimatedTextInput.swift @@ -244,7 +244,7 @@ open class AnimatedTextInput: UIControl { fileprivate func layoutPlaceholderLayer() { // Some letters like 'g' or 'รก' were not rendered properly, the frame need to be about 20% higher than the font size let frameHeightCorrectionFactor: CGFloat = 1.2 - placeholderLayer.frame = CGRect(origin: placeholderPosition, size: CGSize(width: bounds.width, height: style.textInputFont.pointSize * frameHeightCorrectionFactor)) + placeholderLayer.frame = CGRect(origin: placeholderPosition, size: CGSize(width: bounds.width, height: style.placeHolderFont.pointSize * frameHeightCorrectionFactor)) } // mark: Configuration @@ -285,8 +285,8 @@ open class AnimatedTextInput: UIControl { placeholderLayer.masksToBounds = false placeholderLayer.string = placeHolderText placeholderLayer.foregroundColor = style.placeholderInactiveColor.cgColor - placeholderLayer.fontSize = style.textInputFont.pointSize - placeholderLayer.font = style.textInputFont + placeholderLayer.fontSize = style.placeHolderFont.pointSize + placeholderLayer.font = style.placeHolderFont placeholderLayer.contentsScale = UIScreen.main.scale placeholderLayer.backgroundColor = UIColor.clear.cgColor layoutPlaceholderLayer() @@ -337,7 +337,7 @@ open class AnimatedTextInput: UIControl { fileprivate func configurePlaceholderAsDefault() { isPlaceholderAsHint = false - configurePlaceholderWith(fontSize: style.textInputFont.pointSize, + configurePlaceholderWith(fontSize: style.placeHolderFont.pointSize, foregroundColor: style.placeholderInactiveColor.cgColor, text: placeHolderText) lineView.animateToInitialState() @@ -378,9 +378,9 @@ open class AnimatedTextInput: UIControl { fileprivate func styleDidChange() { lineView.defaultColor = style.lineInactiveColor placeholderLayer.foregroundColor = style.placeholderInactiveColor.cgColor - let fontSize = style.textInputFont.pointSize + let fontSize = style.placeHolderFont.pointSize placeholderLayer.fontSize = fontSize - placeholderLayer.font = style.textInputFont + placeholderLayer.font = style.placeHolderFont textInput.view.tintColor = style.activeColor textInput.textColor = style.textInputFontColor textInput.font = style.textInputFont From ddee3f635db622af8637475ca364e9f8d692961e Mon Sep 17 00:00:00 2001 From: DamienBallenghien Date: Thu, 5 Jul 2018 16:35:20 +0200 Subject: [PATCH 2/2] Add placeholderFont property --- AnimatedTextInput/Classes/AnimatedTextInputStyle.swift | 2 ++ 1 file changed, 2 insertions(+) diff --git a/AnimatedTextInput/Classes/AnimatedTextInputStyle.swift b/AnimatedTextInput/Classes/AnimatedTextInputStyle.swift index 5c81b76..1aad94f 100644 --- a/AnimatedTextInput/Classes/AnimatedTextInputStyle.swift +++ b/AnimatedTextInput/Classes/AnimatedTextInputStyle.swift @@ -9,6 +9,7 @@ public protocol AnimatedTextInputStyle { var lineHeight: CGFloat { get } var errorColor: UIColor { get } var textInputFont: UIFont { get } + var placeHolderFont: UIFont { get } var textInputFontColor: UIColor { get } var placeholderMinFontSize: CGFloat { get } var counterLabelFont: UIFont? { get } @@ -31,6 +32,7 @@ public struct AnimatedTextInputStyleBlue: AnimatedTextInputStyle { public let lineHeight: CGFloat = 1.0 / UIScreen.main.scale public let errorColor = UIColor.red public let textInputFont = UIFont.systemFont(ofSize: 14) + public let placeHolderFont = UIFont.systemFont(ofSize: 14) public let textInputFontColor = UIColor.black public let placeholderMinFontSize: CGFloat = 9 public let counterLabelFont: UIFont? = UIFont.systemFont(ofSize: 9)