88
99import  UIKit
1010
11+ /**
12+  An YoshikoTextField is a subclass of the TextFieldEffects object, is a control that displays an UITextField with a customizable visual effect around the edges and background of the control.
13+  */
1114@IBDesignable   public  class  YoshikoTextField :  TextFieldEffects  { 
1215
1316 private  let  borderLayer   =  CALayer ( ) 
1417 private  let  textFieldInsets   =  CGPoint ( x:  6 ,  y:  0 ) 
1518 private  let  placeHolderInsets   =  CGPoint ( x:  6 ,  y:  0 ) 
16-  private  let  outerBackgroundView   =  UIView ( ) 
17- 
19+  
20+  /**
21+  The size of the border.
22+  
23+  This property applies a thickness to the border of the control. The default value for this property is 2 points.
24+  */
1825 @IBInspectable   public  var  borderSize :  CGFloat  =  2.0  { 
1926 didSet { 
2027 updateBorder ( ) 
2128 } 
2229 } 
23- 
24-  @IBInspectable   dynamic  public  var  activeColor :  UIColor  =  . blueColor( )  { 
30+  
31+  /**
32+  The color of the border when it has content.
33+  
34+  This property applies a color to the edges of the control. The default value for this property is a clear color.
35+  */
36+  @IBInspectable   dynamic  public  var  activeBorderColor :  UIColor  =  . clearColor( )  { 
2537 didSet { 
2638 updateBorder ( ) 
2739 updateBackground ( ) 
2840 updatePlaceholder ( ) 
2941 } 
3042 } 
31- 
32-  @IBInspectable   dynamic  public  var  inactiveColor :  UIColor  =  . lightGrayColor( )  { 
43+  
44+  /**
45+  The color of the border when it has no content.
46+  
47+  This property applies a color to the edges of the control. The default value for this property is a clear color.
48+  */
49+  @IBInspectable   dynamic  public  var  inactiveBorderColor :  UIColor  =  . clearColor( )  { 
3350 didSet { 
3451 updateBorder ( ) 
3552 updateBackground ( ) 
3653 updatePlaceholder ( ) 
3754 } 
3855 } 
3956
40-  @IBInspectable   dynamic  public  var  outerBackgroundColor :  UIColor  =  . lightGrayColor( )  { 
41-  didSet { 
42-  updateBorder ( ) 
43-  } 
44-  } 
45- 
46-  @IBInspectable   dynamic  public  var  activeInnerBackgroundColor :  UIColor  =  . clearColor( )  { 
57+  /**
58+  The color of the input's background when it has content. When it's not focused it reverts to the color of the `inactiveBorderColor`
59+  
60+  This property applies a color to the background of the input.
61+  */
62+  @IBInspectable   dynamic  public  var  activeBackgroundColor :  UIColor  =  . clearColor( )  { 
4763 didSet { 
4864 updateBackground ( ) 
4965 } 
5066 } 
51- 
67+  
68+  /**
69+  The color of the placeholder text.
70+  
71+  This property applies a color to the complete placeholder string. The default value for this property is a black color.
72+  */
5273 @IBInspectable   dynamic  public  var  placeholderColor :  UIColor  =  . darkGrayColor( )  { 
5374 didSet { 
5475 updatePlaceholder ( ) 
@@ -66,23 +87,14 @@ import UIKit
6687 private  func  updateBorder( )  { 
6788 borderLayer. frame =  rectForBounds ( bounds) 
6889 borderLayer. borderWidth =  borderSize
69-  borderLayer. borderColor =  ( isFirstResponder ( )  || text!. isNotEmpty)  ?  activeColor . CGColor :  inactiveColor . CGColor
90+  borderLayer. borderColor =  ( isFirstResponder ( )  || text!. isNotEmpty)  ?  activeBorderColor . CGColor :  inactiveBorderColor . CGColor
7091 } 
7192
7293 private  func  updateBackground( )  { 
73-  outerBackgroundView. frame =  CGRect ( origin:  bounds. origin,  size:  CGSize ( width:  bounds. width,  height:  placeholderHeight) ) 
74-  outerBackgroundView. backgroundColor =  outerBackgroundColor
75- 
76-  if  !subviews. contains ( outerBackgroundView)  { 
77-  addSubview ( outerBackgroundView) 
78-  } 
79- 
80-  backgroundColor =  . clearColor( ) 
81-  
8294 if  isFirstResponder ( )  || text!. isNotEmpty { 
83-  layer . backgroundColor =  activeInnerBackgroundColor . CGColor
95+  borderLayer . backgroundColor =  activeBackgroundColor . CGColor
8496 }  else  { 
85-  layer . backgroundColor =  inactiveColor . CGColor
97+  borderLayer . backgroundColor =  inactiveBorderColor . CGColor
8698 } 
8799 } 
88100
@@ -94,7 +106,7 @@ import UIKit
94106 if  isFirstResponder ( )  || text!. isNotEmpty { 
95107 placeholderLabel. font =  placeholderFontFromFontAndPercentageOfOriginalSize ( font:  font!,  percentageOfOriginalSize:  0.5 ) 
96108 placeholderLabel. text =  placeholder? . uppercaseString
97-  placeholderLabel. textColor =  activeColor 
109+  placeholderLabel. textColor =  activeBorderColor 
98110 }  else  { 
99111 placeholderLabel. font =  placeholderFontFromFontAndPercentageOfOriginalSize ( font:  font!,  percentageOfOriginalSize:  0.7 ) 
100112 placeholderLabel. textColor =  placeholderColor
@@ -158,8 +170,8 @@ import UIKit
158170 updateBorder ( ) 
159171 updateBackground ( ) 
160172
161-  addSubview ( placeholderLabel) 
162173 layer. addSublayer ( borderLayer) 
174+  addSubview ( placeholderLabel) 
163175 } 
164176
165177 public  override   func  placeholderRectForBounds( bounds:  CGRect )  ->  CGRect  { 
0 commit comments