Change the text style of Uilabel Objective-C

I'm looking at google on how to change the text style in UILabel, but I got nothing. My text is long, and when I wrote a long text, it displays "When are you ... for me?", But I want it to show "When will you go to the market ...". How can i do Thank you for yours.

+4
source share
3 answers

You must set the property lineBreakModeto your shortcut to NSLineBreakByTruncatingTail. This will take care of it.

+1
source

You can do this in two ways.

option -1

programmatically

Objective-c

label.lineBreakMode = NSLineBreakByTruncatingTail;

Swift

label.lineBreakMode =.byTruncatingTail

other types

  // NSParagraphStyle
typedef NS_ENUM(NSInteger, NSLineBreakMode) {       /* What to do with long lines */
NSLineBreakByWordWrapping = 0,      /* Wrap at word boundaries, default */
NSLineBreakByCharWrapping,      /* Wrap at character boundaries */
NSLineBreakByClipping,      /* Simply clip */
NSLineBreakByTruncatingHead,    /* Truncate at head of line: "...wxyz" */
NSLineBreakByTruncatingTail,    /* Truncate at tail of line: "abcd..." */
NSLineBreakByTruncatingMiddle   /* Truncate middle of line:  "ab...yz" */
}

option -2

using the storyboard attribute inspector

enter image description here

+3

label > Line Breaks, Truncate Tail. ,

yourLabel.lineBreakMode = NSLineBreakByTruncatingTail;
+1

Source: https://habr.com/ru/post/1606914/


All Articles