Iarontalk Blog opens.
The clean and Elegantlife style deduces the deep thought of life.
-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Uilabel as a member of the UIView family, it is widely used, the use of the method is clear and popular enthusiasts like, is the first choice.
The "Multi-line text display" and "AutoFit height to text length" descriptions are used for uilable in the most cut and slightly way.
* * Multi-line display (functional understanding, that is, the completion of input text content, the system automatically according to the width of the text box to do line-wrapping processing) **//
Label.numberoflines = 0;//value is set to 0 o'clock, multiple lines are displayed.
Label.linebreakmode = Uilinebreakmodewordwrap; Wrap Line
* * Automatically adjusts the height of the text box based on the length of text (numeric understanding, that is, when "program Monkey Shoes" is concerned with the height of the text box after the self-adaptation.) )**//
NSString *infodetails = @ "The gorgeous parlor arefull of peaceful and elegant breath, the si-mp-le and slight lightmakes t He romantic taste. Life should is so free inward. ";
This method after 7.0, Apple is not recommended to use, but the method is still very useful, of which 320 is the text input limit width, a high degree of freedom to give.
Cgsize size = [infodetails sizewithfont: [Uifont systemfontofsize:16] Constrainedtosize:[cgsizemake (320,2000)]];
If it is necessary to output the height
NSLog (@ "%d", size.height);
For this method to do the following supplementary instructions, both methods from the function above can be completed text boxes according to their contents of the automatic line-wrap display, but the second method text box height changes as the content changes. For example, in the Comments column of the microblog, the content of the comment is different according to the reviewer, so the height of the text display can be automatically controlled by this method, and the height of the Uilabel is not fixed.
Ios-uilable Multi-line Display text content, automatically calculate text box height based on text length