MDCTextInput

@protocol MDCTextInput <NSObject>

Common API for Material Design compliant text inputs.

  • The attributed text string of the placeholder label. Bringing convenience api found in UITextField to all MDCTextInputs. Maps to the .attributedText of the placeholder label.

    Declaration

    Objective-C

    @property (readwrite, copy, nonatomic, nullable)
        NSAttributedString *attributedPlaceholder;
  • The text displayed in the text input with style attributes.

    Declaration

    Objective-C

    @property (readwrite, copy, nonatomic, nullable)
        NSAttributedString *attributedText;
  • The path of the area to be highlighted with a border. This could either be with a drawn line or a drawn fill.

    Note: The settable properties of the UIBezierPath are respected (.lineWidth, etc).

    Default is a rectangle of the same width as the input with rounded top corners. That means the underline labels are not included inside the border. Settable properties of UIBezierPath are left at system defaults.

    Declaration

    Objective-C

    @property (readwrite, copy, nonatomic, nullable) UIBezierPath *borderPath;
  • The view that implements a bordered or background filled area.

    Declaration

    Objective-C

    @property (readwrite, strong, nonatomic, nullable)
        MDCTextInputBorderView *borderView;
  • A button that can appear inline that when touched clears all entered text and resets the input to an empty state.

    Declaration

    Objective-C

    @property (readonly, strong, nonatomic, nonnull) UIButton *clearButton;
  • Controls when the clear button will display.

    Note: The clear button will never display when there is no entered text.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) UITextFieldViewMode clearButtonMode;
  • The color of the blinking cursor (in the text).

    Applied via .tintColor on the UITextField or UITextView instance.

    Default is [MDCPalette bluePalette].accent700.

    Declaration

    Objective-C

    @property (readwrite, strong, nonatomic, nullable) UIColor *cursorColor;
  • A Boolean value indicating whether the text field is currently in edit mode.

    Declaration

    Objective-C

    @property (readonly, getter=isEditing, assign, nonatomic) BOOL editing;
  • A Boolean value indicating whether the input is enabled.

    The main use of this is to change the appearance when isEnabled = NO to look ‘disabled’.

    Some inputs will inherit this from UIControl.

    Declaration

    Objective-C

    @property (getter=isEnabled, assign, readwrite, nonatomic) BOOL enabled;
  • The font of the text in the input.

    Declaration

    Objective-C

    @property (readwrite, strong, nonatomic, nullable) UIFont *font;
  • Should it have the standard behavior of disappearing when you type? Defaults to YES.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) BOOL hidesPlaceholderOnInput;
  • The label on the leading side under the input.

    This will usually be used for placeholder text to be displayed when no text has been entered. The Material Design guidelines call this ‘helper text.’

    Declaration

    Objective-C

    @property (readonly, strong, nonatomic, nonnull) UILabel *leadingUnderlineLabel;
  • Undocumented

    Declaration

    Objective-C

    @property(nonatomic, setter=mdc_setAdjustsFontForContentSizeCategory:)
        BOOL mdc_adjustsFontForContentSizeCategory
  • The text string of the placeholder label. Bringing convenience api found in UITextField to all MDCTextInputs. Maps to the .text of the placeholder label.

    Declaration

    Objective-C

    @property (readwrite, copy, nonatomic, nullable) NSString *placeholder;
  • The label displaying text when no input text has been entered. The Material Design guidelines call this ‘Hint text.’

    Declaration

    Objective-C

    @property (readonly, strong, nonatomic, nonnull) UILabel *placeholderLabel;
  • An optional delegate that can be queried for important layout information like the text insets for any input and the editing rect, clear button rect for a text field.

    Declaration

    Objective-C

    @property (readwrite, nonatomic, nullable) id<MDCTextInputPositioningDelegate>
        positioningDelegate;
  • The text displayed in the text input.

    Declaration

    Objective-C

    @property (readwrite, copy, nonatomic, nullable) NSString *text;
  • The color of the text in the input.

    Declaration

    Objective-C

    @property (readwrite, strong, nonatomic, nullable) UIColor *textColor;
  • Insets used to calculate the spacing of subviews.

    NOTE: This is always in LTR. It’s automatically flipped when used in RTL.

    Declaration

    Objective-C

    @property (readonly, assign, nonatomic) UIEdgeInsets textInsets;
  • Used to calculate text insets.

    The different options apply to the text insets of the entire text input in relation to the underline labels and the placeholder should any of them be outside the border view.

    MDCTextInputTextInsetsModeNever: Text insets never includes the labels.

    MDCTextInputTextInsetsModeIfContent: Text insets height includes space for each label that has text.

    MDCTextInputTextInsetsModeAlways: Text insets always includes the labels.

    Default is MDCTextInputTextInsetsModeIfContent.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic)
        MDCTextInputTextInsetsMode textInsetsMode;
  • The label on the trailing side under the input.

    This will usually be for the character count / limit.

    Declaration

    Objective-C

    @property (readonly, strong, nonatomic, nonnull) UILabel *trailingUnderlineLabel;
  • An overlay view on the side of the input opposite from where reading and writing lines begin. In LTR this means it will show on the Right side. In LTR, the Left side.

    Declaration

    Objective-C

    @property (readwrite, strong, nonatomic, nullable) UIView *trailingView;
  • Controls when the trailing view will display.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) UITextFieldViewMode trailingViewMode;
  • The underline view

    Declaration

    Objective-C

    @property (readonly, strong, nonatomic, nullable)
        MDCTextInputUnderlineView *underline;
  • A boolean value that indicates whether the text input contains content *

    Declaration

    Objective-C

    @property (readonly, assign, nonatomic) BOOL hasTextContent;
  • Clear the text content in the text input *

    Declaration

    Objective-C

    - (void)clearText;