user3373798
user3373798

Reputation: 81

Word Wrapping on UILabel iOS

Hi friends i have one requirement that word wrapping on label. Using myLabel.lineBreakMode=NSLineBreakByCharWrapping;
I am able to show the text in label like below

Designation    : I am working as iOS 
Developer

But i want to show

Designation    : I am working as iOS 
                Developer

Is this possible to achieve above requirement within one label?
Thanks

Upvotes: 0

Views: 1629

Answers (4)

z22
z22

Reputation: 10083

I tried it and got it solved. I have attached the screenshot. You just need to do the following:

  • set lines property of label to 2.
  • set height and width of the label through xib and its done.

enter image description here

Upvotes: 1

Akshit Zaveri
Akshit Zaveri

Reputation: 4244

Not possible. UILabel just renders text according to properties that you defined. If you want to do it ideally then use two UILabels. & Place them according to your need.

Upvotes: 0

Mani
Mani

Reputation: 17595

No, it's not possible with UILabel, Unless workaround to this. I think, you know how to done manually. But You can't wrap the content like above. Simple answer is you can use two label.

Upvotes: 0

Romain
Romain

Reputation: 3758

In Xcode, you can design your UILabel to have 2 lines. Then, you just need to add a new line ("\n") after the word "iOS", and center-align everything? If your caption is always the same you can pre-enter it in Xcode. To add a new line, just press alt+Enter.

Would that be acceptable?

Upvotes: 0

Related Questions