UILabel adaptive text, making text adaptive and uilabel adaptive
// UILabel adaptive text height
UILabel * label = [[UILabel alloc] initWithFrame: CGRectMake (0,100,300,100)];
Label. numberOfLines = 0;
Label. lineBreakMode = NSLineBreakByWordWrapping;
Label. text = @ "we launched a series of special discounts during the 11 S. Please purchase a limited time! Sofa: diamond quality, leader style! Mattress: elegant and elegant, revealing fashion! Distinguished but luxurious, elegant but natural! We create a warm and romantic life together with you! ";
CGSize size = [label sizeThatFits: CGSizeMake (label. frame. size. width, MAXFLOAT)];
Label. frame = CGRectMake (0,100,300, size. height );
Label. font = [UIFont systemFontOfSize: 14];
[Self. view addSubview: label];
// If you make the text adaptive
// It is often encountered that the display area in UILabel is fixed, but the text in it shows the appropriate font size, you can use the following method:
UILabel * m_titleLabel = [[UILabel alloc] initWithFrame: CGRectMake (200,350, 40, 30)];
M_titleLabel.backgroundColor = [UIColor clearColor];
M_titleLabel.textColor = [UIColor redColor];
M_titleLabel.font = [UIFont systemFontOfSize: 20];
M_titleLabel.adjustsFontSizeToFitWidth = YES;
M_titleLabel.minimumFontSize = 6; // The default value is 0.
M_titleLabel.text = @ "flying in the sky ";
// When the space is sufficient, the font 20 is used. If the space is insufficient, the font will be automatically adjusted downward, but it will not be less than the font 6, if the font 6 is not complete, the ellipsis (...) will be displayed later...
[Self. view addSubview: m_titleLabel];