added method back into code since this is no longer used in VDS.
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
63504ae644
commit
35f322ce08
@ -754,6 +754,37 @@ public typealias ActionBlock = () -> ()
|
|||||||
|
|
||||||
return layoutManager.boundingRect(forGlyphRange: glyphRange, in: textContainer)
|
return layoutManager.boundingRect(forGlyphRange: glyphRange, in: textContainer)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Provides a text container and layout manager of how the text would appear on screen.
|
||||||
|
They are used in tandem to derive low-level TextKit results of the label.
|
||||||
|
*/
|
||||||
|
public func abstractTextContainer() -> (NSTextContainer, NSLayoutManager, NSTextStorage)? {
|
||||||
|
|
||||||
|
// Must configure the attributed string to translate what would appear on screen to accurately analyze.
|
||||||
|
guard let attributedText = attributedText else { return nil }
|
||||||
|
|
||||||
|
let paragraph = NSMutableParagraphStyle()
|
||||||
|
paragraph.alignment = textAlignment
|
||||||
|
|
||||||
|
let stagedAttributedString = NSMutableAttributedString(attributedString: attributedText)
|
||||||
|
stagedAttributedString.addAttributes([NSAttributedString.Key.paragraphStyle: paragraph], range: NSRange(location: 0, length: attributedText.string.count))
|
||||||
|
|
||||||
|
let textStorage = NSTextStorage(attributedString: stagedAttributedString)
|
||||||
|
let layoutManager = NSLayoutManager()
|
||||||
|
let textContainer = NSTextContainer(size: .zero)
|
||||||
|
|
||||||
|
layoutManager.addTextContainer(textContainer)
|
||||||
|
textStorage.addLayoutManager(layoutManager)
|
||||||
|
|
||||||
|
textContainer.lineFragmentPadding = 0.0
|
||||||
|
textContainer.lineBreakMode = lineBreakMode
|
||||||
|
textContainer.maximumNumberOfLines = numberOfLines
|
||||||
|
textContainer.size = bounds.size
|
||||||
|
|
||||||
|
return (textContainer, layoutManager, textStorage)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Atomization
|
// MARK: - Atomization
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user