Commit 994062aa by Daniel Dahan

development: merge after fixing issue-640

parents 11d7c7c4 5c1dac60
......@@ -58,11 +58,6 @@ public protocol TextFieldDelegate: UITextFieldDelegate {
}
open class TextField: UITextField {
/// Will layout the view.
open var willLayout: Bool {
return 0 < width && 0 < height && nil != superview
}
/// Default size when using AutoLayout.
open override var intrinsicContentSize: CGSize {
return CGSize(width: width, height: 32)
......@@ -77,7 +72,7 @@ open class TextField: UITextField {
/// A boolean indicating whether the text is empty.
open var isEmpty: Bool {
return true == text?.isEmpty
return 0 == text?.utf16.count
}
open override var leftView: UIView? {
......@@ -345,11 +340,6 @@ open class TextField: UITextField {
}
}
open override func becomeFirstResponder() -> Bool {
layoutSubviews()
return super.becomeFirstResponder()
}
/**
An initializer that initializes the object with a NSCoder object.
- Parameter aDecoder: A NSCoder instance.
......@@ -377,7 +367,7 @@ open class TextField: UITextField {
open override func layoutSubviews() {
super.layoutSubviews()
guard willLayout && !isAnimating else {
guard !isAnimating else {
return
}
......@@ -385,7 +375,10 @@ open class TextField: UITextField {
reload()
}
open override func becomeFirstResponder() -> Bool {
layoutSubviews()
return super.becomeFirstResponder()
}
/**
Prepares the view instance when intialized. When subclassing,
......@@ -482,12 +475,13 @@ extension TextField {
let w = leftViewWidth
let h = 0 == height ? intrinsicContentSize.height : height
placeholderLabel.transform = CGAffineTransform.identity
guard isEditing || !isEmpty || !isPlaceholderAnimated else {
placeholderLabel.frame = CGRect(x: w, y: 0, width: width - w, height: h)
return
}
placeholderLabel.transform = CGAffineTransform.identity
placeholderLabel.frame = CGRect(x: w, y: 0, width: width - w, height: h)
placeholderLabel.transform = CGAffineTransform(scaleX: 0.75, y: 0.75)
......@@ -505,7 +499,7 @@ extension TextField {
/// Layout the detailLabel.
fileprivate func layoutDetailLabel() {
let c = dividerContentEdgeInsets
detailLabel.sizeToFit()
detailLabel.height = detailLabel.sizeThatFits(CGSize(width: width, height: CGFloat.greatestFiniteMagnitude)).height
detailLabel.x = c.left
detailLabel.y = height + detailVerticalOffset
detailLabel.width = width - c.left - c.right
......@@ -513,10 +507,6 @@ extension TextField {
/// Layout the a button.
fileprivate func layoutButton(button: UIButton?) {
guard 0 < width && 0 < height else {
return
}
button?.frame = CGRect(x: width - height, y: 0, width: height, height: height)
}
......
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