Commit 6ad5b6e5 by Daniel Dahan

Merge pull request #402 from aleufms/development

Added custom placeholderPadding and detailDistance
parents 29775685 0881e196
...@@ -50,6 +50,11 @@ public class TextField : UITextField { ...@@ -50,6 +50,11 @@ public class TextField : UITextField {
} }
} }
/**
This property adds a padding to placeholder y position animation
*/
public var placeholderAnimationPadding: CGFloat = 0
/// A property that accesses the backing layer's backgroundColor. /// A property that accesses the backing layer's backgroundColor.
@IBInspectable public override var backgroundColor: UIColor? { @IBInspectable public override var backgroundColor: UIColor? {
didSet { didSet {
...@@ -228,6 +233,9 @@ public class TextField : UITextField { ...@@ -228,6 +233,9 @@ public class TextField : UITextField {
} }
} }
/// Vertical distance of detail label to divider
public var detailDistance: CGFloat = 8
/// Handles the textAlignment of the placeholderLabel. /// Handles the textAlignment of the placeholderLabel.
public override var textAlignment: NSTextAlignment { public override var textAlignment: NSTextAlignment {
get { get {
...@@ -513,7 +521,7 @@ public class TextField : UITextField { ...@@ -513,7 +521,7 @@ public class TextField : UITextField {
/// Layout the detailLabel. /// Layout the detailLabel.
public func layoutDetailLabel() { public func layoutDetailLabel() {
let h: CGFloat = nil == detail ? 12 : detailLabel.font.stringSize(detail!, constrainedToWidth: Double(width)).height let h: CGFloat = nil == detail ? 12 : detailLabel.font.stringSize(detail!, constrainedToWidth: Double(width)).height
detailLabel.frame = CGRectMake(0, divider.frame.origin.y + 8, width, h) detailLabel.frame = CGRectMake(0, divider.frame.origin.y + detailDistance, width, h)
} }
/// Layout the clearIconButton. /// Layout the clearIconButton.
...@@ -560,7 +568,7 @@ public class TextField : UITextField { ...@@ -560,7 +568,7 @@ public class TextField : UITextField {
v.placeholderLabel.frame.origin.x = v.width - v.placeholderLabel.frame.width v.placeholderLabel.frame.origin.x = v.width - v.placeholderLabel.frame.width
default:break default:break
} }
v.placeholderLabel.frame.origin.y = -v.placeholderLabel.frame.size.height v.placeholderLabel.frame.origin.y = -v.placeholderLabel.frame.size.height + v.placeholderAnimationPadding
v.placeholderLabel.textColor = v.placeholderActiveColor v.placeholderLabel.textColor = v.placeholderActiveColor
} }
}) { [weak self] _ in }) { [weak 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