-1

I have a multi-line label and when the label go to new line i want to get - in the end of line. i am doing it programmatically. How to achieve that? i already try this but its not working

myLabel.lineBreakMode = .byWordWrapping 
myLabel.numberOfLines = 0

In this case label become multiline but - is not added at the end of the line. thanks in advance.

  • 1
    Question is not proper, please add further details like whther you are using storyboard or doing by code and what you'r getting as a output. – dahiya_boy Mar 03 '17 at 13:20

2 Answers2

3

If you're asking how to get hyphenated text, as in:

This is a hyphen-
ated word wrap.

Take a look here: add hyphens on word break in a UILabel

Community
  • 1
  • 1
DonMag
  • 69,424
  • 5
  • 50
  • 86
-2

Above code is working good Try this code just increase the height of the label and width also increased.

enter image description here

 @IBOutlet var labelText: UILabel!
   override func viewDidLoad() {
    super.viewDidLoad()

    labelText.text = "if you know C or Objective-C then you might be familiar with Enums and Structs.However,if you don’t know either of those languages then you are probably"
    labelText.lineBreakMode = .byWordWrapping
    labelText.numberOfLines = 0
}