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