Skip to content

Commit 3321ac1

Browse files
committed
Removed most of the useless color initialisers and made the public properties, public
1 parent 627c3c8 commit 3321ac1

File tree

7 files changed

+24
-22
lines changed

7 files changed

+24
-22
lines changed

TextFieldEffects/TextFieldEffects/HoshiTextField.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@ import UIKit
1010

1111
@IBDesignable public class HoshiTextField: TextFieldEffects {
1212

13-
@IBInspectable var borderInactiveColor: UIColor = UIColor(red: 106, green: 121, blue: 137, alpha: 1) {
13+
@IBInspectable public var borderInactiveColor: UIColor? {
1414
didSet {
1515
updateBorder()
1616
}
1717
}
18-
@IBInspectable var borderActiveColor: UIColor = UIColor(red: 106, green: 121, blue: 137, alpha: 1) {
18+
@IBInspectable public var borderActiveColor: UIColor? {
1919
didSet {
2020
updateBorder()
2121
}
2222
}
23-
@IBInspectable var placeholderColor: UIColor = UIColor(red: 106, green: 121, blue: 137, alpha: 1) {
23+
@IBInspectable public var placeholderColor: UIColor? {
2424
didSet {
2525
updatePlaceholder()
2626
}
@@ -63,10 +63,10 @@ import UIKit
6363

6464
private func updateBorder() {
6565
inactiveBorderLayer.frame = rectForBorder(borderThickness.inactive, isFill: true)
66-
inactiveBorderLayer.backgroundColor = borderInactiveColor.CGColor
66+
inactiveBorderLayer.backgroundColor = borderInactiveColor?.CGColor
6767

6868
activeBorderLayer.frame = rectForBorder(borderThickness.active, isFill: false)
69-
activeBorderLayer.backgroundColor = borderActiveColor.CGColor
69+
activeBorderLayer.backgroundColor = borderActiveColor?.CGColor
7070
}
7171

7272
private func updatePlaceholder() {

TextFieldEffects/TextFieldEffects/IsaoTextField.swift

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ import UIKit
1010

1111
@IBDesignable public class IsaoTextField: TextFieldEffects {
1212

13-
@IBInspectable var inactiveColor: UIColor = UIColor(red: 106, green: 121, blue: 137, alpha: 1) {
13+
@IBInspectable public var inactiveColor: UIColor? {
1414
didSet {
1515
updateBorder()
1616
}
1717
}
18-
@IBInspectable var activeColor: UIColor = UIColor(red: 106, green: 121, blue: 137, alpha: 1) {
18+
@IBInspectable public var activeColor: UIColor? {
1919
didSet {
2020
updateBorder()
2121
}
@@ -56,7 +56,7 @@ import UIKit
5656

5757
private func updateBorder() {
5858
borderLayer.frame = rectForBorder(frame)
59-
borderLayer.backgroundColor = isFirstResponder() ? activeColor.CGColor : inactiveColor.CGColor
59+
borderLayer.backgroundColor = isFirstResponder() ? activeColor?.CGColor : inactiveColor?.CGColor
6060
}
6161

6262
private func updatePlaceholder() {
@@ -109,14 +109,16 @@ import UIKit
109109

110110
override func animateViewsForTextEntry() {
111111
updateBorder()
112-
performPlacerholderAnimationWithColor(activeColor)
113-
112+
if let activeColor = activeColor {
113+
performPlacerholderAnimationWithColor(activeColor)
114+
}
114115
}
115116

116117
override func animateViewsForTextDisplay() {
117118
updateBorder()
118-
performPlacerholderAnimationWithColor(inactiveColor)
119-
119+
if let inactiveColor = inactiveColor {
120+
performPlacerholderAnimationWithColor(inactiveColor)
121+
}
120122
}
121123

122124
private func performPlacerholderAnimationWithColor(color: UIColor) {

TextFieldEffects/TextFieldEffects/JiroTextField.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ import UIKit
1010

1111
@IBDesignable public class JiroTextField: TextFieldEffects {
1212

13-
@IBInspectable var borderColor: UIColor = UIColor(red: 106, green: 121, blue: 137, alpha: 1) {
13+
@IBInspectable public var borderColor: UIColor? {
1414
didSet {
1515
updateBorder()
1616
}
1717
}
18-
@IBInspectable var placeholderColor: UIColor = UIColor(red: 106, green: 121, blue: 137, alpha: 1) {
18+
@IBInspectable public var placeholderColor: UIColor? {
1919
didSet {
2020
updatePlaceholder()
2121
}
@@ -56,7 +56,7 @@ import UIKit
5656

5757
private func updateBorder() {
5858
borderLayer.frame = rectForBorder(borderThickness, isFill: false)
59-
borderLayer.backgroundColor = borderColor.CGColor
59+
borderLayer.backgroundColor = borderColor?.CGColor
6060
}
6161

6262
private func updatePlaceholder() {

TextFieldEffects/TextFieldEffects/KaedeTextField.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ import UIKit
1010

1111
@IBDesignable public class KaedeTextField: TextFieldEffects {
1212

13-
@IBInspectable var placeholderColor: UIColor = UIColor(red: 106, green: 121, blue: 137, alpha: 1) {
13+
@IBInspectable public var placeholderColor: UIColor? {
1414
didSet {
1515
updatePlaceholder()
1616
}
1717
}
1818

19-
@IBInspectable var foregroundColor: UIColor = UIColor(red: 239, green: 239, blue: 239, alpha: 1) {
19+
@IBInspectable public var foregroundColor: UIColor? {
2020
didSet {
2121
updateForegroundColor()
2222
}

TextFieldEffects/TextFieldEffects/MadokaTextField.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ import UIKit
1010

1111
@IBDesignable public class MadokaTextField: TextFieldEffects {
1212

13-
@IBInspectable var placeholderColor: UIColor? {
13+
@IBInspectable public var placeholderColor: UIColor? {
1414
didSet {
1515
updatePlaceholder()
1616
}
1717
}
1818

19-
@IBInspectable var borderColor: UIColor? {
19+
@IBInspectable public var borderColor: UIColor? {
2020
didSet {
2121
updateBorder()
2222
}

TextFieldEffects/TextFieldEffects/MinoruTextField.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import UIKit
1010

1111
@IBDesignable public class MinoruTextField: TextFieldEffects {
1212

13-
@IBInspectable var placeholderColor: UIColor = UIColor(red: 106, green: 121, blue: 137, alpha: 1) {
13+
@IBInspectable public var placeholderColor: UIColor? {
1414
didSet {
1515
updatePlaceholder()
1616
}

TextFieldEffects/TextFieldEffects/YokoTextField.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ import UIKit
1616
}
1717
}
1818

19-
@IBInspectable var placeholderColor: UIColor = UIColor(red: 106, green: 121, blue: 137, alpha: 1) {
19+
@IBInspectable public var placeholderColor: UIColor? {
2020
didSet {
2121
updatePlaceholder()
2222
}
2323
}
2424

25-
@IBInspectable var foregroundColor: UIColor = UIColor(red: 106, green: 121, blue: 137, alpha: 1) {
25+
@IBInspectable public var foregroundColor: UIColor = UIColor.blackColor() {
2626
didSet {
2727
updateForeground()
2828
}

0 commit comments

Comments
 (0)