Commit 6e3438dc by Daniel Dahan

updated TextView to handle lower case characters that extend beyond the frame height

parent 76395176
...@@ -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 = 8 public var titleLabelAnimationDistance: CGFloat = 4
/// 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 = 8 public var detailLabelAnimationDistance: CGFloat = 4
/** /**
:name: detailLabelHidden :name: detailLabelHidden
...@@ -335,7 +335,7 @@ public class TextField : UITextField { ...@@ -335,7 +335,7 @@ public class TextField : UITextField {
} }
/// A multiplier for the titleLabel and detailLabel frame height. /// A multiplier for the titleLabel and detailLabel frame height.
public private(set) var scale: CGFloat = UIScreen.mainScreen().scale 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.
...@@ -416,12 +416,8 @@ public class TextField : UITextField { ...@@ -416,12 +416,8 @@ public class TextField : UITextField {
if interrupted. if interrupted.
*/ */
public override func animationDidStop(anim: CAAnimation, finished flag: Bool) { public override func animationDidStop(anim: CAAnimation, finished flag: Bool) {
if let a: CAPropertyAnimation = anim as? CAPropertyAnimation { if anim is CAPropertyAnimation {
if let b: CABasicAnimation = a as? CABasicAnimation {
layer.setValue(nil == b.toValue ? b.byValue : b.toValue, forKey: b.keyPath!)
}
(delegate as? MaterialAnimationDelegate)?.materialAnimationDidStop?(anim, finished: flag) (delegate as? MaterialAnimationDelegate)?.materialAnimationDidStop?(anim, finished: flag)
layer.removeAnimationForKey(a.keyPath!)
} else if let a: CAAnimationGroup = anim as? CAAnimationGroup { } else if let a: CAAnimationGroup = anim as? CAAnimationGroup {
for x in a.animations! { for x in a.animations! {
animationDidStop(x, finished: true) animationDidStop(x, finished: true)
......
...@@ -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 = 8 public var titleLabelAnimationDistance: CGFloat = 4
/// Placeholder UILabel view. /// Placeholder UILabel view.
public var placeholderLabel: UILabel? { public var placeholderLabel: UILabel? {
...@@ -303,6 +303,9 @@ public class TextView: UITextView { ...@@ -303,6 +303,9 @@ 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.
...@@ -399,12 +402,8 @@ public class TextView: UITextView { ...@@ -399,12 +402,8 @@ public class TextView: UITextView {
if interrupted. if interrupted.
*/ */
public override func animationDidStop(anim: CAAnimation, finished flag: Bool) { public override func animationDidStop(anim: CAAnimation, finished flag: Bool) {
if let a: CAPropertyAnimation = anim as? CAPropertyAnimation { if anim is CAPropertyAnimation {
if let b: CABasicAnimation = a as? CABasicAnimation {
layer.setValue(nil == b.toValue ? b.byValue : b.toValue, forKey: b.keyPath!)
}
(delegate as? MaterialAnimationDelegate)?.materialAnimationDidStop?(anim, finished: flag) (delegate as? MaterialAnimationDelegate)?.materialAnimationDidStop?(anim, finished: flag)
layer.removeAnimationForKey(a.keyPath!)
} else if let a: CAAnimationGroup = anim as? CAAnimationGroup { } else if let a: CAAnimationGroup = anim as? CAAnimationGroup {
for x in a.animations! { for x in a.animations! {
animationDidStop(x, finished: true) animationDidStop(x, finished: true)
...@@ -512,7 +511,7 @@ public class TextView: UITextView { ...@@ -512,7 +511,7 @@ public class TextView: UITextView {
v.text = s v.text = s
} }
} }
let h: CGFloat = v.font.pointSize let h: CGFloat = v.font.pointSize * scale
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