简体   繁体   中英

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

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.

在此处输入图片说明

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?

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM