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 );