Commit 71482c7e by Ramon Vicente

Fix issue #301

parent e3e37a1a
...@@ -631,22 +631,28 @@ public class TextField : UITextField { ...@@ -631,22 +631,28 @@ public class TextField : UITextField {
titleLabel.frame = bounds titleLabel.frame = bounds
titleLabel.font = font titleLabel.font = font
titleLabel.hidden = false titleLabel.hidden = false
UIView.animateWithDuration(0.15, animations: { [unowned self] in UIView.animateWithDuration(0.15, animations: { [weak self] in
self.titleLabel.alpha = 1 if nil != self {
self.titleLabel.transform = CGAffineTransformScale(self.titleLabel.transform, 0.75, 0.75) self!.titleLabel.alpha = 1
self.titleLabel.frame = CGRectMake(0, -(self.titleLabelAnimationDistance + h), self.bounds.width, h) self!.titleLabel.transform = CGAffineTransformScale(self!.titleLabel.transform, 0.75, 0.75)
self!.titleLabel.frame = CGRectMake(0, -(self!.titleLabelAnimationDistance + h), self!.bounds.width, h)
}
}) })
} }
} }
/// Hides and animates the titleLabel property. /// Hides and animates the titleLabel property.
private func hideTitleLabel() { private func hideTitleLabel() {
UIView.animateWithDuration(0.15, animations: { [unowned self] in UIView.animateWithDuration(0.15, animations: { [weak self] in
self.titleLabel.transform = CGAffineTransformIdentity if nil != self {
self.titleLabel.frame = self.bounds self!.titleLabel.transform = CGAffineTransformIdentity
}) { [unowned self] _ in self!.titleLabel.frame = self!.bounds
self.placeholder = self.placeholderText }
self.titleLabel.hidden = true }) { [weak self] _ in
if nil != self {
self!.placeholder = self!.placeholderText
self!.titleLabel.hidden = true
}
} }
} }
...@@ -657,9 +663,11 @@ public class TextField : UITextField { ...@@ -657,9 +663,11 @@ public class TextField : UITextField {
let h: CGFloat = ceil(v.font.lineHeight) let h: CGFloat = ceil(v.font.lineHeight)
v.frame = CGRectMake(0, bounds.height + lineLayerDistance, bounds.width, h) v.frame = CGRectMake(0, bounds.height + lineLayerDistance, bounds.width, h)
v.hidden = false v.hidden = false
UIView.animateWithDuration(0.15, animations: { [unowned self] in UIView.animateWithDuration(0.15, animations: { [weak self] in
v.frame.origin.y = self.frame.height + self.lineLayerDistance + self.detailLabelAnimationDistance if nil != self {
v.alpha = 1 v.frame.origin.y = self!.frame.height + self!.lineLayerDistance + self!.detailLabelAnimationDistance
v.alpha = 1
}
}) })
} }
} }
...@@ -668,9 +676,11 @@ public class TextField : UITextField { ...@@ -668,9 +676,11 @@ public class TextField : UITextField {
/// Hides and animates the detailLabel property. /// Hides and animates the detailLabel property.
private func hideDetailLabel() { private func hideDetailLabel() {
if let v: UILabel = detailLabel { if let v: UILabel = detailLabel {
UIView.animateWithDuration(0.15, animations: { [unowned self] in UIView.animateWithDuration(0.15, animations: { [weak self] in
v.alpha = 0 if nil != self {
v.frame.origin.y -= self.detailLabelAnimationDistance v.alpha = 0
v.frame.origin.y -= self!.detailLabelAnimationDistance
}
}) { _ in }) { _ in
v.hidden = true v.hidden = true
} }
......
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