Commit 76c67232 by Daniel Dahan

updated fix for issue-330

parent 27e62b38
...@@ -79,7 +79,7 @@ class ViewController: UIViewController, TextFieldDelegate { ...@@ -79,7 +79,7 @@ class ViewController: UIViewController, TextFieldDelegate {
emailField.detailLabel!.text = "Email is incorrect." emailField.detailLabel!.text = "Email is incorrect."
emailField.detailLabel!.font = RobotoFont.regularWithSize(12) emailField.detailLabel!.font = RobotoFont.regularWithSize(12)
emailField.detailLabelActiveColor = MaterialColor.red.accent3 emailField.detailLabelActiveColor = MaterialColor.red.accent3
// textField.detailLabelAutoHideEnabled = false // Uncomment this line to have manual hiding. // emailField.detailLabelAutoHideEnabled = false // Uncomment this line to have manual hiding.
view.addSubview(emailField) view.addSubview(emailField)
} }
......
Pod::Spec.new do |s| Pod::Spec.new do |s|
s.name = 'Material' s.name = 'Material'
s.version = '1.39.14' s.version = '1.39.15'
s.license = 'BSD' s.license = 'BSD'
s.summary = 'An animation and graphics framework for Material Design in Swift.' s.summary = 'An animation and graphics framework for Material Design in Swift.'
s.homepage = 'http://cosmicmind.io' s.homepage = 'http://cosmicmind.io'
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>FMWK</string> <string>FMWK</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>1.39.14</string> <string>1.39.15</string>
<key>CFBundleSignature</key> <key>CFBundleSignature</key>
<string>????</string> <string>????</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
......
...@@ -369,12 +369,10 @@ public class TextField : UITextField { ...@@ -369,12 +369,10 @@ public class TextField : UITextField {
/// An override to the text property. /// An override to the text property.
@IBInspectable public override var text: String? { @IBInspectable public override var text: String? {
didSet { didSet {
textFieldDidChange() handleValueChanged()
if(!editing){ if !editing && (nil == text || text!.isEmpty) {
if text == nil || text!.isEmpty { hideTitleLabel()
hideTitleLabel() }
}
}
} }
} }
...@@ -515,14 +513,14 @@ public class TextField : UITextField { ...@@ -515,14 +513,14 @@ public class TextField : UITextField {
prepareClearButton() prepareClearButton()
prepareTitleLabel() prepareTitleLabel()
prepareLineLayer() prepareLineLayer()
addTarget(self, action: #selector(textFieldDidBegin), forControlEvents: .EditingDidBegin) addTarget(self, action: #selector(handleEditingDidBegin), forControlEvents: .EditingDidBegin)
addTarget(self, action: #selector(textFieldDidChange), forControlEvents: .EditingChanged) addTarget(self, action: #selector(handleEditingChanged), forControlEvents: .EditingChanged)
addTarget(self, action: #selector(textFieldDidEnd), forControlEvents: .EditingDidEnd) addTarget(self, action: #selector(handleEditingDidEnd), forControlEvents: .EditingDidEnd)
addTarget(self, action: #selector(textFieldValueChanged), forControlEvents: .ValueChanged) addTarget(self, action: #selector(handleValueChanged), forControlEvents: .ValueChanged)
} }
/// Handler for text changed. /// Handler for editing changed.
internal func textFieldDidChange() { internal func handleEditingChanged() {
sendActionsForControlEvents(.ValueChanged) sendActionsForControlEvents(.ValueChanged)
} }
...@@ -531,11 +529,11 @@ public class TextField : UITextField { ...@@ -531,11 +529,11 @@ public class TextField : UITextField {
if false == delegate?.textFieldShouldClear?(self) { if false == delegate?.textFieldShouldClear?(self) {
return return
} }
text = "" text = nil
} }
/// Ahdnler when text value changed. /// Ahdnler when text value changed.
internal func textFieldValueChanged() { internal func handleValueChanged() {
if detailLabelAutoHideEnabled && !detailLabelHidden { if detailLabelAutoHideEnabled && !detailLabelHidden {
detailLabelHidden = true detailLabelHidden = true
lineLayer.backgroundColor = (nil == lineLayerActiveColor ? titleLabelActiveColor : lineLayerActiveColor)?.CGColor lineLayer.backgroundColor = (nil == lineLayerActiveColor ? titleLabelActiveColor : lineLayerActiveColor)?.CGColor
...@@ -543,7 +541,7 @@ public class TextField : UITextField { ...@@ -543,7 +541,7 @@ public class TextField : UITextField {
} }
/// Handler for text editing began. /// Handler for text editing began.
internal func textFieldDidBegin() { internal func handleEditingDidBegin() {
showTitleLabel() showTitleLabel()
placeholder = nil placeholder = nil
titleLabel.textColor = titleLabelActiveColor titleLabel.textColor = titleLabelActiveColor
...@@ -552,10 +550,7 @@ public class TextField : UITextField { ...@@ -552,10 +550,7 @@ public class TextField : UITextField {
} }
/// Handler for text editing ended. /// Handler for text editing ended.
internal func textFieldDidEnd() { internal func handleEditingDidEnd() {
if 0 == text?.utf16.count {
hideTitleLabel()
}
titleLabel.textColor = titleLabelColor titleLabel.textColor = titleLabelColor
lineLayer.frame.size.height = lineLayerThickness lineLayer.frame.size.height = lineLayerThickness
lineLayer.backgroundColor = (detailLabelHidden ? nil == lineLayerColor ? titleLabelColor : lineLayerColor : nil == lineLayerDetailColor ? detailLabelActiveColor : lineLayerDetailColor)?.CGColor lineLayer.backgroundColor = (detailLabelHidden ? nil == lineLayerColor ? titleLabelColor : lineLayerColor : nil == lineLayerDetailColor ? detailLabelActiveColor : lineLayerDetailColor)?.CGColor
...@@ -586,8 +581,6 @@ public class TextField : UITextField { ...@@ -586,8 +581,6 @@ public class TextField : UITextField {
if 0 < text?.utf16.count { if 0 < text?.utf16.count {
showTitleLabel() showTitleLabel()
} else {
titleLabel.alpha = 0
} }
} }
...@@ -650,7 +643,6 @@ public class TextField : UITextField { ...@@ -650,7 +643,6 @@ public class TextField : UITextField {
titleLabel.hidden = false titleLabel.hidden = false
UIView.animateWithDuration(0.15, animations: { [weak self] in UIView.animateWithDuration(0.15, animations: { [weak self] in
if let v: TextField = self { if let v: TextField = self {
v.titleLabel.alpha = 1
v.titleLabel.transform = CGAffineTransformScale(v.titleLabel.transform, 0.75, 0.75) v.titleLabel.transform = CGAffineTransformScale(v.titleLabel.transform, 0.75, 0.75)
v.titleLabel.frame = CGRectMake(0, -(v.titleLabelAnimationDistance + h), v.bounds.width, h) v.titleLabel.frame = CGRectMake(0, -(v.titleLabelAnimationDistance + h), v.bounds.width, h)
} }
......
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