UILabel, uilabel wrap

Source: Internet
Author: User

UILabel, uilabel wrap

// UILabel-> UIView

/*

1. instantiation

2. Attributes

3. Add to parent View

*/

// Instantiate

UILabel * label = [[UILabel alloc] initWithFrame: CGRectMake (20,100,280, 30)];

// Attributes

Label. backgroundColor = [UIColor redColor];

Label. alpha = 1.0;

Label. hidden = NO;

// Attributes that are unique to you

// Display text attributes: text

Label. text = @ "Do not say goodbye, please refer to them again when you say ";

// Text color: Black by default: textColor

Label. textColor = [UIColor blueColor];

// Set font size: font

Label. font = [UIFont systemFontOfSize: 18.0];

// Set the font size (with italicSystemFontOfSize)

// Label. font = [UIFont italicSystemFontOfSize: 18.0];

// Set the font size (with BOLD effect): boldSystemFontOfSize

Label. font = [UIFont boldSystemFontOfSize: 18.0];

// Alignment: textAlignment

/*

1. NSTextAlignmentCenter

2. NSTextAlignmentLeft is left aligned. Default Value:

3. NSTextAlignmentRight right

*/

Label. textAlignment = NSTextAlignmentLeft;

// Set the number of rows: numberOfLines; numbers greater than 0: number of rows to be written; 0: automatic line feed

Label. numberOfLines = 0;

// Adaptive text size: adjustsFontSizeToFitWidth

// Label. adjustsFontSizeToFitWidth = YES;

// Adaptive label height

[Label sizeToFit];

// Shadow effect of Text

Label. shadowColor = [UIColor whiteColor];

// Shadow offset

Label. shadowOffset = CGSizeMake (5, 5 );

// Locate the overall font family

NSArray * familyName = [UIFont familyNames];

For (NSString * name in familyName ){

// Find the font name in the font family

NSArray * fontName = [UIFont fontNamesForFamilyName: name];

For (NSString * font in fontName ){

// Find the specified font name

NSLog (@ "% @", font );

}

}

// Add to parent View

[Self. window addSubview: label];

// Create the second UILabel and use the specific font to initialize it.

UILabel * label2 = [[UILabel alloc] initWithFrame: CGRectMake (20,220,280, 80)];

Label2.backgroundColor = [UIColor cyanColor];

Label2.text = @ "hello hi everyOne ";

Label2.textColor = [UIColor redColor];

Label2.textAlignment = NSTextAlignmentCenter;

// Set font with the exact font

Label2.font = [UIFont fontWithName: @ "Thonburi" size: 18.0];

[Self. window addSubview: label2];

// Obtain the screen width

CGFloat width = self. window. frame. size. width;

// Obtain the height of the entire Screen

CGFloat height = self. window. frame. size. height;

NSLog (@ "% f", width, height );

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.