Commit 030d3fb7 by Daniel Dahan

updated TextField and TextView with a better fix for the corpping text issue

parent 38e92483
...@@ -169,7 +169,6 @@ public class NavigationBarView : MaterialView { ...@@ -169,7 +169,6 @@ public class NavigationBarView : MaterialView {
} }
public override func intrinsicContentSize() -> CGSize { public override func intrinsicContentSize() -> CGSize {
// General alignment.
switch UIDevice.currentDevice().orientation { switch UIDevice.currentDevice().orientation {
case .LandscapeLeft, .LandscapeRight: case .LandscapeLeft, .LandscapeRight:
return CGSizeMake(UIScreen.mainScreen().bounds.width, 44) return CGSizeMake(UIScreen.mainScreen().bounds.width, 44)
......
...@@ -273,7 +273,7 @@ public class TextField : UITextField { ...@@ -273,7 +273,7 @@ public class TextField : UITextField {
A property that sets the distance between the textField and A property that sets the distance between the textField and
titleLabel. titleLabel.
*/ */
public var titleLabelAnimationDistance: CGFloat = 4 public var titleLabelAnimationDistance: CGFloat = 8
/// An override to the text property. /// An override to the text property.
public override var text: String? { public override var text: String? {
...@@ -311,7 +311,7 @@ public class TextField : UITextField { ...@@ -311,7 +311,7 @@ public class TextField : UITextField {
A property that sets the distance between the textField and A property that sets the distance between the textField and
detailLabel. detailLabel.
*/ */
public var detailLabelAnimationDistance: CGFloat = 4 public var detailLabelAnimationDistance: CGFloat = 8
/** /**
:name: detailLabelHidden :name: detailLabelHidden
...@@ -334,9 +334,6 @@ public class TextField : UITextField { ...@@ -334,9 +334,6 @@ public class TextField : UITextField {
} }
} }
/// A multiplier for the titleLabel and detailLabel frame height.
public private(set) var scale: CGFloat = 2
/** /**
An initializer that initializes the object with a NSCoder object. An initializer that initializes the object with a NSCoder object.
- Parameter aDecoder: A NSCoder instance. - Parameter aDecoder: A NSCoder instance.
...@@ -528,7 +525,7 @@ public class TextField : UITextField { ...@@ -528,7 +525,7 @@ public class TextField : UITextField {
v.text = s v.text = s
} }
} }
let h: CGFloat = v.font.pointSize * scale let h: CGFloat = ceil(v.font.lineHeight)
v.frame = CGRectMake(0, -h, bounds.width, h) v.frame = CGRectMake(0, -h, bounds.width, h)
v.hidden = false v.hidden = false
UIView.animateWithDuration(0.25, animations: { [unowned self] in UIView.animateWithDuration(0.25, animations: { [unowned self] in
...@@ -555,7 +552,7 @@ public class TextField : UITextField { ...@@ -555,7 +552,7 @@ public class TextField : UITextField {
private func showDetailLabel() { private func showDetailLabel() {
if let v: UILabel = detailLabel { if let v: UILabel = detailLabel {
if v.hidden { if v.hidden {
let h: CGFloat = v.font.pointSize * scale let h: CGFloat = ceil(v.font.lineHeight)
v.frame = CGRectMake(0, bounds.height + bottomBorderLayerDistance, bounds.width, h) v.frame = CGRectMake(0, bounds.height + bottomBorderLayerDistance, bounds.width, h)
v.hidden = false v.hidden = false
UIView.animateWithDuration(0.25, animations: { [unowned self] in UIView.animateWithDuration(0.25, animations: { [unowned self] in
......
...@@ -263,7 +263,7 @@ public class TextView: UITextView { ...@@ -263,7 +263,7 @@ public class TextView: UITextView {
A property that sets the distance between the textView and A property that sets the distance between the textView and
titleLabel. titleLabel.
*/ */
public var titleLabelAnimationDistance: CGFloat = 4 public var titleLabelAnimationDistance: CGFloat = 8
/// Placeholder UILabel view. /// Placeholder UILabel view.
public var placeholderLabel: UILabel? { public var placeholderLabel: UILabel? {
...@@ -303,9 +303,6 @@ public class TextView: UITextView { ...@@ -303,9 +303,6 @@ public class TextView: UITextView {
} }
} }
/// A multiplier for the titleLabel and detailLabel frame height.
public private(set) var scale: CGFloat = 2
/** /**
An initializer that initializes the object with a NSCoder object. An initializer that initializes the object with a NSCoder object.
- Parameter aDecoder: A NSCoder instance. - Parameter aDecoder: A NSCoder instance.
...@@ -511,7 +508,7 @@ public class TextView: UITextView { ...@@ -511,7 +508,7 @@ public class TextView: UITextView {
v.text = s v.text = s
} }
} }
let h: CGFloat = v.font.pointSize * scale let h: CGFloat = ceil(v.font.lineHeight)
v.frame = CGRectMake(0, -h, bounds.width, h) v.frame = CGRectMake(0, -h, bounds.width, h)
v.hidden = false v.hidden = false
UIView.animateWithDuration(0.25, animations: { [unowned self] in UIView.animateWithDuration(0.25, animations: { [unowned self] in
......
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