Commit 5c1dac60 by Daniel Dahan

master: issue-640: Fixed issue where TextField was not laying out correctly when…

master: issue-640: Fixed issue where TextField was not laying out correctly when setting programmatic text.
parent bd2a6901
Pod::Spec.new do |s|
s.name = 'Material'
s.version = '2.4.5'
s.version = '2.4.6'
s.license = 'BSD-3-Clause'
s.summary = 'Material is an animation and graphics framework that brings Material Design to iOS with Swift 3.'
s.homepage = 'http://materialswift.com'
......
......@@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>2.4.5</string>
<string>2.4.6</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
......
......@@ -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