how to remove three dots from UILabel?
Asked Answered
B

5

16

I have a UILabel that contains text that is bigger than the label size. (The UILabel has 2 lines.)

The UILabel is showing the three dots (ellipsis) on iOS. I do not want label to show this dots. How can I make them not show?

Battalion answered 1/7, 2015 at 9:53 Comment(2)
Do you want to resize to fitting its text?Law
no . about Do you want to resize to fitting its text? label size is constantBattalion
L
35

Set the label's lineBreakMode to .ByClipping(Swift) or NSLineBreakByClipping(Objective-C).

Law answered 1/7, 2015 at 9:55 Comment(4)
when label text "text 1 text 2 text 3 text 4 \n \n \n \n \n \n" in this case when first line is"text 1 text 2 text 3" there are still 3 dots after "text 4 " on second line . In other cases like for same label uses text"text 1 text 1 text 1 text 1 text 1 text 1 text 1 text 1 text 1" It can helpBattalion
i fix it by adding space character " " var theLabelTextString = "text 1 text 1 text 1 text 1" for iter in 0...20 { theLabelTextString += " " }Battalion
using both lineBreakMode and many space character " " before \n \n \n \n \n \n solved my case . thanksBattalion
You can also do this in Interface Builder's UILabel settings. Set Line Breaks to ClipBleary
E
6

Programmatically,

nameLabel.lineBreakMode = .byClipping

Eldin answered 3/3, 2019 at 10:6 Comment(0)
C
1

Please add code

[labelname sizeToFit];
Cribbing answered 1/7, 2015 at 9:55 Comment(0)
C
1

I have achieved by following steps:

1.Increase height of label as I did so that 2 lines fit.

2.select label, go to attributes inspector

3.select Line Breaks = Word Wrap

4.also increase lines, like 2,3

changing line break in attributes inspector changing line break in attributes inspector

Worked for me

Compulsion answered 9/1, 2016 at 9:40 Comment(0)
G
0

If you don't want to fit the size or show the three dots, you need to set your label like this.

Objective-C

[label setLineBreakMode: NSLineBreakByClipping];

Swift

label.lineBreakMode = .byClipping
Gregorio answered 6/2, 2020 at 7:42 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.