From 79c4c7354fea54b033be13d3b2fd5338ae0e1bc1 Mon Sep 17 00:00:00 2001 From: hipposan Date: Tue, 16 May 2017 15:30:50 +0800 Subject: [PATCH] Fixed Storyboard crash when no placeholder is set --- Spring/DesignableTextField.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Spring/DesignableTextField.swift b/Spring/DesignableTextField.swift index ecaf442..d209fa9 100644 --- a/Spring/DesignableTextField.swift +++ b/Spring/DesignableTextField.swift @@ -26,7 +26,9 @@ import UIKit @IBInspectable public var placeholderColor: UIColor = UIColor.clear { didSet { - attributedPlaceholder = NSAttributedString(string: placeholder!, attributes: [NSForegroundColorAttributeName: placeholderColor]) + guard let placeholder = placeholder else { return } + + attributedPlaceholder = NSAttributedString(string: placeholder, attributes: [NSForegroundColorAttributeName: placeholderColor]) layoutSubviews() }