IOS basics-UILabel

Source: Internet
Author: User

IOS basics-UILabel

The most common text tag. To put it bluntly, it is a collection of strings used to display text.

The following describes the label attributes in detail.

 

-(Void) viewDidLoad {[super viewDidLoad]; UILabel * label = [[UILabel alloc] init]; // set the displayed text label. text = @ "this is a text control"; // set the label of the displayed text font. font = [UIFont systemFontOfSize: 18.0]; // set the text color label. textColor = [UIColor redColor]; // sets the shadow color label. shadowColor = [UIColor greenColor]; // sets the shadow size label. shadowOffset = CGSizeMake (1.0, 1.0);/* typedef NS_ENUM (NSInteger, NSTextAlignment) {NSTextAlignmentLeft = 0, // Align left # if iphone NSTextAlignmentCenter = 1, // center NSTextAlignmentRight = 2, // align right # else ipad NSTextAlignmentRight = 1, // always ally right aligned NSTextAlignmentCenter = 2, // Visually centered # endif other NSTextAlignmentJustified = 3, // align with the section NSTextAlignmentNatural = 4, // The default state is normal} NS_ENUM_AVAILABLE_IOS (6_0 ); * /// text display mode label. textAlignment = NSTextAlignmentCenter; // set the automatic line feed, but it is expired in ios Abel. lineBreakMode = UILineBreakModeCharacterWrap; // you can use this line feed label now. numberOfLines = 0; // set the text color label in the highlighted state. highlightedTextColor = [UIColor greenColor]; // set the minimum font value, but minimumFontSize has expired. minimumFontSize = 18.0; label. minimumScaleFactor = 18.0; // sets whether the control object size is automatically adjusted with the title content. [label setAutoresizesSubviews: true]; // sets whether users can operate the label. userInteractionEnabled = NO; // set the control status to available label. enabled = YES ;/ /Specifies the maximum line width to calculate the inherent content size. * UILabel and NSTextField are ambiguous for the inherent content size of multi-line text. The height of the text depends on the width of the line, which is also a problem to be clarified when solving the constraints. To solve this problem, both classes have a property called preferredMaxLayoutWidth, which specifies the maximum line width to calculate the inherent content size. */Label. preferredMaxLayoutWidth = 19.0; // set whether to reduce the text font to adapt to the label area label. bytes = NO;/* typedef NS_ENUM (NSInteger, UIBaselineAdjustment) {bytes = 0, // The top of the default text is the label midline alignment; // The text midline is the label midline alignment UIBaselineAdjustmentNone, // align the lowest-end text with the label midline}; * // set the baseline position label of the text. baselineAdjustment = UIBaselineAdjustmentAlignBaselines; // Add the text to the Controller view [self. view addSubview: label];


 

Related Article

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.