Uilabel, we all know, will be shown at the end when the content is insufficient...
However, when you set attributedstring for uilabel, you will find that although the content is insufficient, the final...
This may be because the original setting of uilabel does not take effect after attributedstring is set (including font, font color, and other attributes)
If you want to display... manually set the truncation mode for uilabel
Nsmutableattributedstring * string = [[nsmutableattributedstring alloc] initwithstring: @ "one of London's landmark buildings is a bridge across the river, which was opened to traffic in 1984. the engine structure was used for bridge upgrading and downgrading. bridge Opening in order to let high ships pass through the scene wgqrgqwrfrgqwe "]; nsmutableparagraphstyle * Paragraph = [[nsmutableparagraphstyle alloc] init]; label. numberoflines = 0; // paragraph. linespacing = 20; // paragraph. paragraphspacing = 20; nsdictionary * attributes = @ {attributes: [uifont systemfontofsize: 17366f], attributes: paragraph}; [String addattributes: Attributes range: nsmakerange (0, String. length)]; [label setattributedtext: String]; label. linebreakmode = nslinebreakbytruncatingtail;
After attributedtext is set, setting linebreakmode will take effect. If attributedtext is re-set in the subsequent code, you need to re-set the linebreakmode. Otherwise, the linebreakmode of the label will be overwritten, no...
If you think the above method is troublesome, another solution is to use
Nsmutableparagraphstyle also has a linebreakmode which can be set to the truncation mode. This mode is directly added to attributedstring, so you do not need to set the linebreakmode of uilabel.