Is there a way to have multiple lines of text in UILabel
like in the UITextView
or should I use the second one instead?
相关问题
- Core Data lightweight migration crashes after App
- How can I implement password recovery in an iPhone
- State preservation and restoration strategies with
- “Zero out” sensitive String data in Swift
- Get the NSRange for the visible text after scroll
相关文章
- 现在使用swift开发ios应用好还是swift?
- UITableView dragging distance with UIRefreshContro
- TCC __TCCAccessRequest_block_invoke
- Where does a host app handle NSExtensionContext#co
- Xcode: Is there a way to change line spacing (UI L
- Swift - hide pickerView after value selected
- How do you detect key up / key down events from a
- didBeginContact:(SKPhysicsContact *)contact not in
Set below either in code or in storyboard itself
Label.lineBreakMode = NSLineBreakByWordWrapping; Label.numberOfLines = 0;
and please don't forget to set left, right, top and bottom constraints for label otherwise it won't work.
I agree with Jarred Olson, NSLineBreakByWordWrapping is default. I added property sizeToFit like the guide of Gurumoorthy Arumugam to fix it.
If you want the font inside your label to adjust itself to fit into the boundaries of the label. You can use :
Thanks all.
This code is returning size height according to text
In this function pass string that you want to assign in label and pass font size in place of self.activityFont and pass label width in place of 235, now you get label height according to your string. it will work fine.
Swift 4: