Skip to content

Commit 141c2b0

Browse files
committed
Allow setting the placeholder font scale
1 parent 5ed9280 commit 141c2b0

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

TextFieldEffects/TextFieldEffects/HoshiTextField.swift

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import UIKit
3737

3838
/**
3939
The color of the placeholder text.
40-
40+
4141
This property applies a color to the complete placeholder string. The default value for this property is a black color.
4242
*/
4343
@IBInspectable dynamic public var placeholderColor: UIColor = .blackColor() {
@@ -46,6 +46,17 @@ import UIKit
4646
}
4747
}
4848

49+
/**
50+
The scale of the placeholder font.
51+
52+
This property determines the size of the placeholder label relative to the font size of the text field.
53+
*/
54+
@IBInspectable dynamic public var placeholderFontScale: CGFloat = 0.65 {
55+
didSet {
56+
updatePlaceholder()
57+
}
58+
}
59+
4960
override public var placeholder: String? {
5061
didSet {
5162
updatePlaceholder()
@@ -133,7 +144,7 @@ import UIKit
133144
}
134145

135146
private func placeholderFontFromFont(font: UIFont) -> UIFont! {
136-
let smallerFont = UIFont(name: font.fontName, size: font.pointSize * 0.65)
147+
let smallerFont = UIFont(name: font.fontName, size: font.pointSize * placeholderFontScale)
137148
return smallerFont
138149
}
139150

0 commit comments

Comments
 (0)