I have a UIBarButtonItem in a UIToolbar that updates with a change in the name represented by the text box. The text field should not have a short maximum length. When the title is quite long, the element covers the button elements on the right. How can I make it automatically crop to a specific width?
Use a custom view with the widest possible width, textAlignment set to UITextAlignmentCenter and lineBreakMode to UILineBreakModeTailTruncation .
textAlignment
UITextAlignmentCenter
lineBreakMode
UILineBreakModeTailTruncation
UILabel* l = [[[UILabel alloc]initWithFrame:CGRectMake(0, 0, 200, 20)]autorelease]; //200 is just a number I choose. you should calculate your maximum possible value l.textAlignment = UITextAlignmentCenter; l.lineBreakMode = UILineBreakModeTailTruncation; self.navigationItem.titleView = l;
You can also set the width in the Storyboard Size Inspector:
Source: https://habr.com/ru/post/893081/More articles:Fire event if custom CSS style changes? - javascriptSIFT Training in OpenCV - cAdd / remove many of the many associations in the Entity Framework - c #https://translate.googleusercontent.com/translate_c?depth=1&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/893079/entity-model-how-to-move-entity-models-generated-entity-classes-to-a-separate-assembly&usg=ALkJrhiH0V6mESgeKSMCXwsv4RTss0ZySASSMS does not show or does not script the attribute FILESTREAM - sql-server-2008Can ASP.NET MVC generate elements with the smallest names and identifier attributes - asp.net-mvcAdd an external link to the list of tabs on your Facebook page - facebookJQuery mobile headers overlap with long text - jqueryMove the rectangles so that they do not overlap - performanceArray.Reverse () compared to Enumerable.Reverse () - .netAll Articles