Use of UILabel, use of UILabel

Source: Internet
Author: User

Use of UILabel, use of UILabel

// Create UILabel

UILabel * label = [[UILabelalloc] initWithFrame: CGRectMake (150, 50)];

// Set the background color

Label. backgroundColor = [UIColorgreenColor];

// Set the displayed content

Label. text = @ "hahahahahahahahaha ";

// Set the font size. The default font size is 17. Use the default font style.

// Label. font = [UIFont systemFontOfSize: 14.0f];

// Label. font = [UIFont boldSystemFontOfSize: 14.0f];

// Set the font style and size

Label. font = [UIFontfontWithName: @ "Hoefler Text" size: 16366f];

// Set the rounded corner attributes

Label. layer. cornerRadius = 5;

// Obtain the names of all fonts

// NSArray * names = [UIFont familyNames];

// Set the alignment mode. The default value is left.

Label. textAlignment = NSTextAlignmentCenter;

// Set the font color. The default value is black.

Label. textColor = [UIColorredColor];

// Set the number of lines to be displayed. The default value is one line. If multiple lines are set, the height is sufficient.

// Label. numberOfLines = 2;

// If it is set to 0, multiple rows are displayed.

Label. numberOfLines = 0;

// Set to automatically adjust the width and height. Make sure there is content before setting it.

[Label sizeToFit];


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.