Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions Source/MKTextField.swift
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@ public class MKTextField : UITextField {
updateFloatingLabelText()
}
}

override public var attributedPlaceholder: NSAttributedString? {
didSet {
updateFloatingLabelText()
}
}

override public var bounds: CGRect {
didSet {
mkLayer.superLayerDidResize()
Expand Down Expand Up @@ -125,7 +132,11 @@ public class MKTextField : UITextField {

override public func layoutSubviews() {
super.layoutSubviews()


bottomBorderLayer?.backgroundColor = isFirstResponder() ? tintColor.CGColor : bottomBorderColor.CGColor
let borderWidth = isFirstResponder() ? bottomBorderHighlightWidth : bottomBorderWidth
bottomBorderLayer?.frame = CGRect(x: 0, y: layer.bounds.height - borderWidth, width: layer.bounds.width, height: borderWidth)

if !floatingPlaceholderEnabled {
return
}
Expand All @@ -138,10 +149,6 @@ public class MKTextField : UITextField {
} else {
hideFloatingLabel()
}

bottomBorderLayer?.backgroundColor = isFirstResponder() ? tintColor.CGColor : bottomBorderColor.CGColor
let borderWidth = isFirstResponder() ? bottomBorderHighlightWidth : bottomBorderWidth
bottomBorderLayer?.frame = CGRect(x: 0, y: layer.bounds.height - borderWidth, width: layer.bounds.width, height: borderWidth)
}

override public func textRectForBounds(bounds: CGRect) -> CGRect {
Expand Down Expand Up @@ -198,7 +205,7 @@ private extension MKTextField {
}

private func updateFloatingLabelText() {
floatingLabel.text = placeholder
floatingLabel.attributedText = attributedPlaceholder
floatingLabel.sizeToFit()
setFloatingLabelOverlapTextField()
}
Expand Down