Use UILabel to display static text to show users static text and control the font and color of text. @ Property (nonatomic, strong) UILabel * myLabel; @ synthesize myLabel;-(void) viewDidLoad {[super viewDidLoad]; self. view. backgroundColor = [UIColor whiteColor]; CGRect labelFrame = CGRectMake (0.0f, 0.0f, 100366f, 23.0f); self. myLabel = [[UILabel alloc] initWithFrame: labelFrame]; self. myLabel. text = @ "hello world"; self. myLabel. font = [UIFont boldSystemFontOfSize: 14.0f]; self. myLabel. numberOfLines = 3; // number of lines in the text Self. myLabel. adjustsFontSizeToFitWidth = YES; // The label view remains static, and the font in the label can be automatically adjusted to the border suitable for the label. Self. myLabel. center = self. view. center; [self. view addSubview: self. myLabel];} Use UITextField to accept user text input (31 pixels by default) @ property (nonatomic, strong) UITextField * myTextField; @ synthesize myTextField;-(void) viewDidLoad {[super viewDidLoad]; self. view. backgroundColor = [UIColor whiteColor]; CGRect textFieldFrame = CGRectMake (0.0f, 0.0f, 200366f, 31.0f); self. myTextField = [[UITextField alloc] initWithFrame: textFieldF Rame]; self. myTextField. borderStyle = UITextBorderStyleRoundedRect; // Text View border self. myTextField. contentverticalignment = UIControlContentVerticalAlignmentCenter; // center the text view vertically by self. myTextField. textAlignment = UITextAlignmentCenter; // text horizontal alignment mode self. myTextField. text = @ "hello world"; self. myTextField. center = self. view. center; [self. view addSubview: self. myTextField];} UITextFieldDelegate protocol textFieldShouldBe GinEditing: // BOOL sets whether the text view can be edited. textFieldDidBeginin: // this method is called when the user starts to edit the text view. TextFieldShouldEndEditing: // This method returns a BOOL value, which indicates whether the text view ends the current editing process. If NO is returned, you cannot end text editing. TextFieldDidEndEditing: it is called when the editing process of the text view is terminated. TextField: shouldChangeCharacterInRange: replacementString: This method is called when the text in the text view is modified. The return value is a Boolean value. NO. modifications to the text in the text view will not be notified or occurred. YES indicates that the text can be modified. TextFieldShouldClear: each text view has a clear button, usually a Circular X button. TextFieldShouldReturn: When you press return or enter on the keyboard, this method is called to hide the keyboard. You need to register this text view as the first responder of this method. @ Property (nonatomic, strong) UITextField * myTextField; @ property (nonatomic, strong) UILabel * labelCounter; @ synthesize myTextField; @ synthesize labelCounter;-(void) handle :( NSString *) paramText {NSString * characterOrCharacters = @ "Characters"; if ([paramText length] = 1) {characterOrCharacters = @ "Character";} self. labelCounter. text = [NSString stringWithFormat: @ "% lu % @ ", (Unsigned long) [paramText length], characterOrCharacters];}-(BOOL) textField :( UITextField *) textField shouldChangeCharactersInRange :( nsange) range replacementString :( NSString *) string {BOOL result = YES; if ([textField isEqual: self. myTextField]) {NSString * wholeText = [textField. text stringByReplacingCharactersInRange: range withString: string]; [self calculateAndDisplayTextFieldLengthWithText: whole Text];} return result;}-(BOOL) textFieldShouldReturn :( UITextField *) textField {[textField resignFirstResponder]; return YES;}-(void) viewDidLoad {[super viewDidLoad]; self. view. backgroundColor = [UIColor whileColor]; CGRect textFieldFrame = CGRectMake (38366f, 30366f, 220366f, 31.0f); self. myTextField = [[UITextField alloc] initWithFrame: textFieldFrame]; self. myTextField. delegate = self; self. myTextField. B OrderStyle = UITextBorderStyleRounderRect; self. myTextField. contentverticalignment = custom; self. myTextField. text = @ "hello world"; self. myTextField. placeholder = @ "Enter text here... "; Self. view addSubview: self. myTextField]; CGRect labelCounterFrame = self. myTextField. frame; labelCounterFrame. origin. y + = textFieldFrame. size. height + 10; self. labelCounter = [[UILabel alloc] initWithFrame: labelCounterFrame]; [self. view addSubview: self. labelCounter]; [self calculateAndDisplayTextFieldLengthWithText]; [self calculateAndDisplayTextFieldLengthWithText: selfTextField. text];} The text view has two opposite Properties, which are leftView and rightView. UILabel * currencyLabel = [[UILabel alloc] initWithFrame: CGRectZero]; currencyLabel. text = [[[NSNumberFormatter alloc] init] currencySymbol]; currencyLabel. font = self. myTextField. font; [currencyLabel sizeToFit]; self. myTextField. leftView = currencyLabel; self. myTextField. leftViewMode = UITextFieldViewModeAlways; typedef enum {UITextfieldViewModeNever, UITextFieldViewModeWhileEditing, // If a value has been declared for it, when the user edits this The Left view is displayed in the text view. UITextFieldViewModeUnlessEditing, // when the user does not edit the text in the Text View, the Left view will be displayed, but once you start editing, the view will disappear. Response} UITextFieldViewMode; Use UITextView to display the text field @ property (nonatomic, strong) UItextView * myTextView; @ synthesize myTextView;-(void) viewDidLoad {[super viewDidLoad]; self. view. backgroundColor = [UIColor whileColor]; self. myTextView = [[UITextView alloc] initWithFrame: self. view. bounds]; self. myTextView. text = @ "hello world"; self. myTextView. font = [UIFont systemFontOfSize: 16366f]; self. View addSubView: self. myTextView];} If you click "Text view", the virtual keyboard overwrites the area of the text view. What should we do? To make up for this defect, we need to listen for some pending notifications: UIKeyboardWillShowNotification // This notification will be sent to any part, such as the text view, when the keyboard is preparing to display the sub-screen. UIKeyboardDidShowNotification // This notification will be sent when the keyboard is already displayed on the screen. UIKeyboardWIllHideNotification // when the keyboard is about to be hidden, a notification will be sent to UIKeyboardDidHideNotification // when the keyboard is completely hidden, this notification will be sent, so our policy is to find out when the keyboard is ready to be on the screen. display and then adjust the view. -(Void) handleKeyBoardDidShow :( NSNotification *) paramNotification {NSValue * keyboardRectAsObject = [[paramNotification userInfo] objectForKey: Keys];/* get the frame of the keyboard */CGRect keyboardRect; [keyboardRectAsObject getValue: & keyboardRect];/* place it in a CGRect */self. myTextView. contentInset = UIEdgeInsetsMake (0.0f, 0.0f, keyboarddRect. size. height, 0.0f);}-(void) handle KeyboardWillHide :( NSNotification *) paramNotification {self. myTextView. contentInset = UIEdgeInsetsZero;/* make the text view as the whole view again */}-(void) viewWillAppear :( BOOL) paramAnimated {[super viewWillAppear: paramAnimated]; [[nsicationcenter center defacenter center] addObserver: self selector: @ selector (handleKeyboardDidShow :) name: UIKeyboardDidShowNotification object: nil]; [nsicationicationicationcenter DefaultCenter] addObserver: self selector: @ selector (handleKeyboardWillHide :) name: UIKeyboardWillHideNotification object: nil]; self. view. backgroundColor = [UIColor whiteColor]; self. myTextView = [[UITextView alloc] initWithFrame: self. view. bounds]; self. myTextView. text = @ "" hello world ......; Self. myTextView. font = [UIFont systemFontOfSize: 16366f]; [self. view addSubview: self. myTextView];}-(void) viewWillDisappear :( BOOL) paramAnimated {[super viewWillDisappear: paramAnimated]; [[nsicationicationcenter defacenter center] removeObserver: self];} in this code, in method viewWillAppear: start to build a keyboard notification and end the listener in method viewWillDisappear.