File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -98,4 +98,9 @@ IB_DESIGNABLE
9898 */
9999@property (nonatomic ) IBInspectable CGSize errorPadding;
100100
101+ /* *
102+ * The text that is displayed above the text field when there is input.
103+ */
104+ @property (nonatomic ) NSString *floatingLabelText;
105+
101106@end
Original file line number Diff line number Diff line change @@ -206,6 +206,12 @@ - (void)setAttributedText:(NSAttributedString *)attributedText
206206 [self updateDefaultPlaceholderFont ];
207207}
208208
209+ - (void )setFloatingLabelText : (NSString *)floatingLabelText
210+ {
211+ _floatingLabelText = floatingLabelText;
212+ [self updatePlaceholderText ];
213+ }
214+
209215- (void )setPlaceholder : (NSString *)placeholder
210216{
211217 [super setPlaceholder: placeholder];
@@ -492,7 +498,8 @@ - (void)hidePlaceholderLabelAnimated:(BOOL)animated
492498
493499- (void )updatePlaceholderText
494500{
495- self.placeholderLabel .text = self.placeholder ?: self.placeholderAttributedString .string ;
501+ NSString * actualPlaceholder = self.placeholder ?: self.placeholderAttributedString .string ;
502+ self.placeholderLabel .text = self.floatingLabelText ?: actualPlaceholder;
496503 [self .placeholderLabel sizeToFit ];
497504 [self invalidateIntrinsicContentSize ];
498505}
You can’t perform that action at this time.
0 commit comments