Summary of common UI Methods --- UILabel UITextField (continuously updating) and uilabeluitextfield

Source: Internet
Author: User

Summary of common UI Methods --- UILabel UITextField (continuously updating) and uilabeluitextfield

UILabel: UIView <NSCoding>

1. Create a UILabel object

UILabel * label = [[UILabelalloc] initWithFrame: CGRectMake (30,30, 280,60)];


2. backgroundColor

Background Color


3. text

Displayed text information

Eg: label. text = @ "displayed text ";


4. textColor

Text color

Eg: label. textColor = [UIColoryellowColor];


5. shadowColor

Text shadow color

Eg: label. shadowColor = [UIColorblueColor];


6. shadowOffset

Text shadow offset

Eg: label. shadowOffset = CGSizeMake (3, 3 );


7. textAlignment

Text format processing (alignment)

Eg: label. textAlignment = NSTextAlignmentCenter;


8. lineBreakMode

When the text is too long, the label displays the broken line mode.

Eg: label. lineBreakMode = NSLineBreakByTruncatingHead;


9. numberOfLines

Control the number of lines displayed by the label

Eg: label. numberOfLines = 0;


10. font

Font size: default font size: 17

Eg: label. font = [UIFontsystemFontOfSize: 20];




UITextField: UIControl <UITextInput, NSCoding>


1. Create a UITextField object

UITextField * name = [[UITextFieldalloc] initWithFrame: CGRectMake (30,100,280, 30)];


2. placeholder

The default placeholder string is automatically hidden once input.

Eg: name. placeholder = @ "Enter here ";


3. secureTextEntry

Input to Black Point

Eg: name. secureTextEntry = YES;


4. keyboardType

Change the keyboard type

Name. keyboardType = UIKeyboardTypeASCIICapable;


5. borderStyle

Appearance Control

Name. borderStyle = UITextBorderStyleRoundedRect;


6. clearButtonMode

Clear button

Name. clearButtonMode = UITextFieldViewModeWhileEditing;


7. backgroundColor

Background Color


8. Reclaim the keyboard

[TextField resignFirstResponder];


9.-(BOOL) textFieldShouldBeginEditing :( UITextField *) textField;

// Whether input is allowed


10.-(BOOL) textField :( UITextField *) textField shouldChangeCharactersInRange :( nsange) range replacementString :( NSString *) string;

// Restrict input characters

Eg: if ([stringisEqualToString: @ "a"]) {

ReturnNO;

}

NSLog (@ "% @", string );

ReturnYES;


11.-(BOOL) textFieldShouldReturn :( UITextField *) textField;

// Return button call Method


What is the difference between UITextField UILabel in IOS? UITextField inherits UIControl UILabel and UIView;

UITextField can be edited and input, but UILabel cannot. When UITextField is input, a proxy responds to the operation.
I do not particularly understand what you compare them with and where you want to use them. I have a premise that you can only understand what you said.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.