MDCTextInputController

@protocol MDCTextInputController <NSObject, NSCopying,
                                  MDCTextInputPositioningDelegate>

Controllers that manipulate styling and animation of text inputs.

  • Color for decorations that indicates the input is currently editing.

    Default is activeColorDefault.

    Declaration

    Objective-C

    @property (readwrite, strong, nonatomic, null_resettable) UIColor *activeColor;
  • Default value for activeColor.

    Declaration

    Objective-C

    @property (readwrite, strong, nonatomic, null_resettable, class)
        UIColor *activeColorDefault;
  • The character counter. Override to use a custom character counter.

    Default is an internal instance MDCTextInputAllCharactersCounter. Setting this property to null will reset it to return that instance.

    Declaration

    Objective-C

    @property (readwrite, nonatomic, null_resettable)
        id<MDCTextInputCharacterCounter>
            characterCounter;
  • The character count maximum for the text input. A label under the input counts characters entered and presents the count / the max.

    If character count / max has been hidden by the characterCountViewMode (ie: UITextFieldViewModeNever) changing the value of characterLimit has no effect.

    If the character count goes above its max, the underline, the character count / max label and any floating placeholder label all turn to the error color; the text input will be in error state. Note: setErrorText:errorAccessibilityValue: also sets these MDCTextInput properties.

    There is no support for a minimum character count.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) NSUInteger characterCountMax;
  • Controls when the character count will be shown and therefore whether character counting determines error state.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic)
        UITextFieldViewMode characterCountViewMode;
  • Color for decorations that indicates the input is not enabled / not accepting touch.

    Default is disabledColorDefault.

    Declaration

    Objective-C

    @property (readwrite, strong, nonatomic, null_resettable) UIColor *disabledColor;
  • Default value for disabledColor.

    Declaration

    Objective-C

    @property (readwrite, strong, nonatomic, null_resettable, class)
        UIColor *disabledColorDefault;
  • The color used to denote error state in decorations, the errorText’s label, the placeholder and the character count label.

    Default is errorColorDefault.

    Declaration

    Objective-C

    @property (readwrite, strong, nonatomic, null_resettable) UIColor *errorColor;
  • Default value for errorColor.

    Declaration

    Objective-C

    @property (readwrite, strong, nonatomic, null_resettable, class)
        UIColor *errorColorDefault;
  • The text being displayed in the leading underline label when in an error state.

    NOTE: To set this value, you must use setErrorText:errorAccessibilityValue:.

    Declaration

    Objective-C

    @property (readonly, copy, nonatomic, nullable) NSString *errorText;
  • Text displayed in the leading underline label.

    This text should give context or instruction to the user. If error text is set, it is not shown.

    Declaration

    Objective-C

    @property (readwrite, copy, nonatomic, nullable) NSString *helperText;
  • The color applied to the placeholder when inline (not floating).

    Default is inlinePlaceholderColorDefault.

    Declaration

    Objective-C

    @property (readwrite, strong, nonatomic, null_resettable)
        UIColor *inlinePlaceholderColor;
  • Default value for inlinePlaceholderColor.

    Declaration

    Objective-C

    @property (readwrite, strong, nonatomic, null_resettable, class)
        UIColor *inlinePlaceholderColorDefault;
  • The font applied to the text input.

    Default or in case this property is nil, the value will be textInputFontDefault. If textInputFontDefault is nil, textInput.font would be the fallback.

    Declaration

    Objective-C

    @property (readwrite, strong, nonatomic, null_resettable) UIFont *textInputFont;
  • Default value for textInputFontDefault. If nil, textInput.font would be the fallback.

    Declaration

    Objective-C

    @property (readwrite, strong, nonatomic, nullable, class)
        UIFont *textInputFontDefault;
  • The font applied to the placeholder when inline (not floating).

    Default is inlinePlaceholderFontDefault;

    Declaration

    Objective-C

    @property (readwrite, strong, nonatomic, null_resettable)
        UIFont *inlinePlaceholderFont;
  • Default value for inlinePlaceholderFont.

    Declaration

    Objective-C

    @property (readwrite, strong, nonatomic, null_resettable, class)
        UIFont *inlinePlaceholderFontDefault;
  • The font applied to the leading side underline label.

    Default is leadingUnderlineLabelFontDefault.

    Declaration

    Objective-C

    @property (readwrite, strong, nonatomic, null_resettable)
        UIFont *leadingUnderlineLabelFont;
  • Default value for leadingUnderlineLabelFont.

    Declaration

    Objective-C

    @property (readwrite, strong, nonatomic, null_resettable, class)
        UIFont *leadingUnderlineLabelFontDefault;
  • The color applied to the leading side underline label when not in error state.

    Default is leadingUnderlineLabelTextColorDefault.

    Declaration

    Objective-C

    @property (readwrite, strong, nonatomic, null_resettable)
        UIColor *leadingUnderlineLabelTextColor;
  • Default value for leadingUnderlineLabelTextColor.

    Declaration

    Objective-C

    @property (readwrite, strong, nonatomic, null_resettable, class)
        UIColor *leadingUnderlineLabelTextColorDefault;
  • Undocumented

    Declaration

    Objective-C

    @property(nonatomic, assign, readwrite, setter=mdc_setAdjustsFontForContentSizeCategory:)
        BOOL mdc_adjustsFontForContentSizeCategory
  • Default value for mdc_adjustsFontForContentSizeCategory.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic, class)
        BOOL mdc_adjustsFontForContentSizeCategoryDefault;
  • Color for decorations that indicates the input is enabled but not currently editing.

    Default is normalColorDefault.

    Declaration

    Objective-C

    @property (readwrite, strong, nonatomic, null_resettable) UIColor *normalColor;
  • Default value for normalColor.

    Declaration

    Objective-C

    @property (readwrite, strong, nonatomic, null_resettable, class)
        UIColor *normalColorDefault;
  • The text displayed in the placeholder label.

    Declaration

    Objective-C

    @property (readwrite, copy, nonatomic, nullable) NSString *placeholderText;
  • The corners to be rounded in the border area.

    Default is roundedCornersDefault.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) UIRectCorner roundedCorners;
  • Default for roundedCorners.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic, class)
        UIRectCorner roundedCornersDefault;
  • The text input the controller is affecting.

    Declaration

    Objective-C

    @property (readwrite, strong, nonatomic, nullable)
        UIView<MDCTextInput> *textInput;
  • The tintColor applied to the textInput’s clear button. See @c UIImageView.tintColor for additional details.

    Declaration

    Objective-C

    @property (readwrite, strong, nonatomic, null_resettable)
        UIColor *textInputClearButtonTintColor;
  • Default value for @c textInputClearButtonTintColor.

    Declaration

    Objective-C

    @property (readwrite, strong, nonatomic, nullable, class)
        UIColor *textInputClearButtonTintColorDefault;
  • The font applied to the trailing side underline label.

    Default is trailingUnderlineLabelFontDefault.

    Declaration

    Objective-C

    @property (readwrite, strong, nonatomic, null_resettable)
        UIFont *trailingUnderlineLabelFont;
  • Default value for trailingUnderlineLabelFont.

    Declaration

    Objective-C

    @property (readwrite, strong, nonatomic, null_resettable, class)
        UIFont *trailingUnderlineLabelFontDefault;
  • The color applied to the trailing side underline label when not in error state.

    Default is trailingUnderlineLabelTextColorDefault.

    Declaration

    Objective-C

    @property (readwrite, strong, nonatomic, nullable)
        UIColor *trailingUnderlineLabelTextColor;
  • Default value for trailingUnderlineLabelTextColor.

    Declaration

    Objective-C

    @property (readwrite, strong, nonatomic, nullable, class)
        UIColor *trailingUnderlineLabelTextColorDefault;
  • Height of the underline when text field is first responder.

    Default is underlineHeightActiveDefault.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) CGFloat underlineHeightActive;
  • Default value for underlineHeightActive.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic, class)
        CGFloat underlineHeightActiveDefault;
  • Height of the underline when NOT first responder.

    Default is underlineHeightNormalDefault.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) CGFloat underlineHeightNormal;
  • Default value for underlineHeightNormal.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic, class)
        CGFloat underlineHeightNormalDefault;
  • Controls when the underline will be shown.

    The underline is an overlay that can be hidden depending on the editing state of the input text.

    Default is underlineViewModeDefault.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) UITextFieldViewMode underlineViewMode;
  • Default value for underlineViewMode.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic, class)
        UITextFieldViewMode underlineViewModeDefault;
  • Convenience init. Never fails.

    Declaration

    Objective-C

    - (nonnull instancetype)initWithTextInput:
        (nullable UIView<MDCTextInput> *)input;

    Parameters

    input

    An MDCTextInput this controller will manage.

  • Sets the state of the controller by setting the values of properties errorText and errorAccessibilityValue.

    The value of errorText controls the state of the text input.

    This method is usually called from whatever object is the UITextFieldDelegate for the MDCTextField. That object is responsible for validation of the text and calling this method if the error state needs to change.

    When errorText != nil, the text input is in an error state:

    • The error text appears in the underline text with the errorColor as text color.
    • The input rectangle’s underline, placeholder and character are colored to the errorColor.

    When errorText == nil, the text input is not in error state:

    • The underline text is restored to the color and value it was.
    • The underline color and height is restored.
    • The placeholder text is restored to the color it was.
    • The character count text is restored to the color it was.

    Setting errorText to an empty string (@“”) will put the input in error state but the underline text will be empty. It will color (if visible) the underline, the placeholder, and the character count in the errorColor.

    Setting errorAccessibilityValue when errorText == nil has no effect.

    Note: The characterCountMax property also affects these same MDCTextInput properties.

    Declaration

    Objective-C

    - (void)setErrorText:(nullable NSString *)errorText
        errorAccessibilityValue:(nullable NSString *)errorAccessibilityValue;

    Parameters

    errorText

    The error text to be shown as underline text. (Copied.)

    errorAccessibilityValue

    Optional override of default underline text accessibility value. (Copied.)

  • Sets helper text and a corresponding accessibilityLabel.

    If the TextField is in an error state helperText is saved as the previousLeadingText, and helperAccessibilityLabel is saved in an instance variable. When the TextField eventually leaves the error state the previousLeadingText becomes the leadingUnderlineLabel’s text and the helperAccessibilityLabel becomes the leadingUnderlinLabel’s accessibilityLabel.

    If the TextField is not in an error state helperText is set as the leadingUnderlineLabel’s text and helperAccessibilityLabel is set as the leadingUnderlineLabel’s accessibilityLabel.

    Declaration

    Objective-C

    - (void)setHelperText:(nullable NSString *)helperText
        helperAccessibilityLabel:(nullable NSString *)helperAccessibilityLabel;

    Parameters

    helperText

    The helper text to be shown as leading underline text. (Copied.)

    helperAccessibilityLabel

    Optional override of leading underline accessibilityLabel when helper text is displayed. (Copied.)