From 037e3d8aea46c4c1cef3d9df7c30766c384c0fc2 Mon Sep 17 00:00:00 2001 From: osaral Date: Thu, 26 Nov 2015 18:59:04 +0200 Subject: [PATCH 1/3] fixed disabling floating placeholder doesn't let you set bottom border color --- Source/MKTextField.swift | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Source/MKTextField.swift b/Source/MKTextField.swift index c17b820..816911a 100644 --- a/Source/MKTextField.swift +++ b/Source/MKTextField.swift @@ -125,7 +125,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 } @@ -138,10 +142,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 { From 8786252b61cdb7e40212c387e92b6536298e09fc Mon Sep 17 00:00:00 2001 From: osaral Date: Tue, 8 Dec 2015 17:58:01 +0200 Subject: [PATCH 2/3] added attributedPlaceholder --- Source/MKTextField.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/MKTextField.swift b/Source/MKTextField.swift index 816911a..0dc892f 100644 --- a/Source/MKTextField.swift +++ b/Source/MKTextField.swift @@ -198,7 +198,7 @@ private extension MKTextField { } private func updateFloatingLabelText() { - floatingLabel.text = placeholder + floatingLabel.attributedText = attributedPlaceholder floatingLabel.sizeToFit() setFloatingLabelOverlapTextField() } From 7c99c487c12aa880b5b28a75a0f48a6af8236d29 Mon Sep 17 00:00:00 2001 From: osaral Date: Mon, 14 Dec 2015 16:41:57 +0200 Subject: [PATCH 3/3] fixed attributed placeholder --- Source/MKTextField.swift | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Source/MKTextField.swift b/Source/MKTextField.swift index 0dc892f..6236d04 100644 --- a/Source/MKTextField.swift +++ b/Source/MKTextField.swift @@ -77,6 +77,13 @@ public class MKTextField : UITextField { updateFloatingLabelText() } } + + override public var attributedPlaceholder: NSAttributedString? { + didSet { + updateFloatingLabelText() + } + } + override public var bounds: CGRect { didSet { mkLayer.superLayerDidResize()