File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -97,4 +97,9 @@ IB_DESIGNABLE
9797 */
9898@property (nonatomic ) IBInspectable CGFloat errorPadding;
9999
100+ /* *
101+ * The text that is displayed above the text field when there is input.
102+ */
103+ @property (nonatomic ) NSString *floatingLabelText;
104+
100105@end
Original file line number Diff line number Diff line change @@ -195,6 +195,12 @@ - (void)setAttributedText:(NSAttributedString *)attributedText
195195 [self updateDefaultPlaceholderFont ];
196196}
197197
198+ - (void )setFloatingLabelText : (NSString *)floatingLabelText
199+ {
200+ _floatingLabelText = floatingLabelText;
201+ [self updatePlaceholderText ];
202+ }
203+
198204- (void )setPlaceholder : (NSString *)placeholder
199205{
200206 [super setPlaceholder: placeholder];
@@ -478,7 +484,8 @@ - (void)hidePlaceholderLabelAnimated:(BOOL)animated
478484
479485- (void )updatePlaceholderText
480486{
481- self.placeholderLabel .text = self.placeholder ?: self.placeholderAttributedString .string ;
487+ NSString * actualPlaceholder = self.placeholder ?: self.placeholderAttributedString .string ;
488+ self.placeholderLabel .text = self.floatingLabelText ?: actualPlaceholder;
482489 [self .placeholderLabel sizeToFit ];
483490 [self invalidateIntrinsicContentSize ];
484491}
You can’t perform that action at this time.
0 commit comments