iOS UITextField

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!

Introduction

UITextField is part of UIKit framework and is used to display an area to collect text input from the user using the onscreen keyboard

Syntax

  • UITextField.text: String // get or set the text the field displays.
  • UITextField.attributedText: NSAttributedString // get or set the attributed text the field displays.
  • UITextField.textColor: UIColor // get or set the color of the text on the field
  • UITextField.font: UIFont // get or set the font of the text on the field
  • UITextField.textAlignment: NSTextAlignment // default is NSLeftTextAlignment
  • UITextField.borderStyle: UITextBorderStyle // default is UITextBorderStyleNone. If set to UITextBorderStyleRoundedRect, custom background images are ignored.
  • UITextField.placeholder: String // default is nil. string is drawn 70% gray
  • UITextField.attributedPlaceholder: NSAttributedString // get or set the attributed placeholder of the field
  • UITextField.clearsOnBeginEditing: Bool // default is NO which moves cursor to location clicked. if YES, all text cleared
  • UITextField.adjustsFontSizeToFitWidth: Bool // default is NO. if YES, text will shrink to minFontSize along baseline
  • UITextField.minimumFontSize: CGFloat // default is 0.0. actual min may be pinned to something readable. used if adjustsFontSizeToFitWidth is YES
  • UITextField.delegate: UITextFieldDelegate? // default is nil. weak reference
  • UITextField.clearButtonMode: UITextFieldViewMode // sets when the clear button shows up. default is UITextFieldViewModeNever
  • UITextField.leftView: UIView? // e.g. magnifying glass
  • UITextField.leftViewMode: UITextFieldViewMode // sets when the left view shows up. default is UITextFieldViewModeNever
  • UITextField.rightView: UIView? // e.g. bookmarks button
  • UITextField.rightViewMode: UITextFieldViewMode // sets when the right view shows up. default is UITextFieldViewModeNever
  • UITextField.inputView: UIView? // Presented when object becomes first responder. If set to nil, reverts to following responder chain. If set while first responder, will not take effect until reloadInputViews is called.
  • UITextField.inputAccessoryView: UIView?
  • UITextField.isSecureTextEntry : Bool // e.g If field contain confidential input like password or card number


Got any iOS Question?