Commit 3c738247 by Daniel Dahan

development: fixed alignment when initially calling on

parent 89833757
...@@ -50,7 +50,7 @@ public class TextField: UITextField { ...@@ -50,7 +50,7 @@ public class TextField: UITextField {
} }
/// Reference to the divider. /// Reference to the divider.
public private(set) lazy var divider: CAShapeLayer = CAShapeLayer() public private(set) var divider: CAShapeLayer!
/// Divider height. /// Divider height.
@IBInspectable public var dividerHeight: CGFloat = 1 @IBInspectable public var dividerHeight: CGFloat = 1
...@@ -108,7 +108,7 @@ public class TextField: UITextField { ...@@ -108,7 +108,7 @@ public class TextField: UITextField {
} }
/// The placeholder UILabel. /// The placeholder UILabel.
@IBInspectable public private(set) lazy var placeholderLabel: UILabel = UILabel(frame: CGRect.zero) @IBInspectable public private(set) var placeholderLabel: UILabel!
/// Placeholder textColor. /// Placeholder textColor.
@IBInspectable public var placeholderColor: UIColor = Color.darkText.others { @IBInspectable public var placeholderColor: UIColor = Color.darkText.others {
...@@ -291,7 +291,6 @@ public class TextField: UITextField { ...@@ -291,7 +291,6 @@ public class TextField: UITextField {
public override func layoutSubviews() { public override func layoutSubviews() {
super.layoutSubviews() super.layoutSubviews()
layoutToSize() layoutToSize()
} }
...@@ -305,7 +304,8 @@ public class TextField: UITextField { ...@@ -305,7 +304,8 @@ public class TextField: UITextField {
/// Handles the text editing did begin state. /// Handles the text editing did begin state.
public func handleEditingDidBegin() { public func handleEditingDidBegin() {
dividerEditingDidBeginAnimation() layoutIfNeeded()
dividerEditingDidBeginAnimation()
placeholderEditingDidBeginAnimation() placeholderEditingDidBeginAnimation()
} }
...@@ -342,11 +342,10 @@ public class TextField: UITextField { ...@@ -342,11 +342,10 @@ public class TextField: UITextField {
*/ */
public func prepareView() { public func prepareView() {
super.placeholder = nil super.placeholder = nil
clipsToBounds = false clipsToBounds = false
borderStyle = .none borderStyle = .none
backgroundColor = nil backgroundColor = nil
textColor = Color.darkText.primary textColor = Color.darkText.primary
font = RobotoFont.regularWithSize(size: 16)
contentScaleFactor = Device.scale contentScaleFactor = Device.scale
prepareDivider() prepareDivider()
preparePlaceholderLabel() preparePlaceholderLabel()
...@@ -354,11 +353,11 @@ public class TextField: UITextField { ...@@ -354,11 +353,11 @@ public class TextField: UITextField {
prepareTargetHandlers() prepareTargetHandlers()
prepareTextAlignment() prepareTextAlignment()
} }
/// Ensures that the components are sized correctly. /// Ensures that the components are sized correctly.
public func layoutToSize() { public func layoutToSize() {
if !animating { if !animating {
layoutPlaceholderLabel() layoutPlaceholderLabel()
layoutDetailLabel() layoutDetailLabel()
layoutClearIconButton() layoutClearIconButton()
layoutVisibilityIconButton() layoutVisibilityIconButton()
...@@ -482,14 +481,17 @@ public class TextField: UITextField { ...@@ -482,14 +481,17 @@ public class TextField: UITextField {
/// Prepares the divider. /// Prepares the divider.
private func prepareDivider() { private func prepareDivider() {
divider = CAShapeLayer()
dividerColor = Color.darkText.dividers dividerColor = Color.darkText.dividers
layer.addSublayer(divider) layer.addSublayer(divider)
} }
/// Prepares the placeholderLabel. /// Prepares the placeholderLabel.
private func preparePlaceholderLabel() { private func preparePlaceholderLabel() {
placeholderLabel = UILabel(frame: CGRect.zero)
placeholderColor = Color.darkText.others placeholderColor = Color.darkText.others
addSubview(placeholderLabel) font = RobotoFont.regularWithSize(size: 16)
addSubview(placeholderLabel)
} }
/// Prepares the detailLabel. /// Prepares the detailLabel.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment