I have a label with multiple lines, lineBreakMode is set to UILineBreakModeWordWrap. How can I determine width of last line?
相关问题
- 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
UPDATE Swift 4.2 (IOS 12)
Usage
I found that NSLayoutManager has provide API for this:
so, I think we can do it like this:
Since iOS 7.0 you can do it using this function (Maybe you'll have to tweak text container a bit more for your case):
Objective-C:
Then you can decide if there is enough place for your date label in the last line or not
usage example:
Here's how I did it. First put your label's lines in NSArray, and then check width of last line. In viewDidLoad:
And getSeparatedLinesFromLbl: