@@ -44,6 +44,7 @@ import UIKit
4444////////////////////////////////////////////////////////////////////////////////
4545
4646
47+ @IBDesignable
4748public class ICTokenField : UIView , UITextFieldDelegate , ICBackspaceTextFieldDelegate {
4849
4950 /// The receiver’s delegate.
@@ -58,7 +59,7 @@ public class ICTokenField: UIView, UITextFieldDelegate, ICBackspaceTextFieldDele
5859 }
5960
6061 /// The image on the left of text field.
61- public var icon : UIImage ? {
62+ @ IBInspectable public var icon : UIImage ? {
6263 didSet {
6364 if let icon = icon {
6465 let imageView = UIImageView ( image: icon)
@@ -77,7 +78,7 @@ public class ICTokenField: UIView, UITextFieldDelegate, ICBackspaceTextFieldDele
7778 }
7879
7980 /// The placeholder with the default color and font.
80- public var placeholder : String ? {
81+ @ IBInspectable public var placeholder : String ? {
8182 get {
8283 return attributedPlaceholder? . string
8384 }
@@ -213,6 +214,19 @@ public class ICTokenField: UIView, UITextFieldDelegate, ICBackspaceTextFieldDele
213214 layoutTokenTextField ( )
214215 }
215216
217+ // MARK: - NSKeyValueCoding
218+
219+ public override func setValue( value: AnyObject ? , forUndefinedKey key: String ) {
220+ switch value {
221+ case let image as UIImage ? where key == " icon " :
222+ icon = image
223+ case let text as String ? where key == " placeholder " :
224+ placeholder = text
225+ default :
226+ break
227+ }
228+ }
229+
216230 // MARK: - UITextFieldDelegate
217231
218232 public func textFieldShouldBeginEditing( textField: UITextField ) -> Bool {
@@ -340,8 +354,6 @@ public class ICTokenField: UIView, UITextFieldDelegate, ICBackspaceTextFieldDele
340354 frame = CGRect ( x: 0 , y: 7 , width: UIScreen . mainScreen ( ) . bounds. width, height: 30 )
341355 }
342356
343- backgroundColor = UIColor . whiteColor ( )
344-
345357 addSubview ( scrollView)
346358 scrollView. addSubview ( inputTextField)
347359 scrollView. translatesAutoresizingMaskIntoConstraints = false
0 commit comments