Current solution to widow word.

This commit is contained in:
Kevin G Christiano 2019-12-02 15:59:44 -05:00
parent 88e079e6be
commit 8b0d208047

View File

@ -685,13 +685,20 @@ extension Label {
/// Converts the entire text into a link. All characters will be underlined and the intrinsic bounds will respond to tap.
@objc public func makeTextButton(actionBlock: @escaping ActionBlock) {
setTextLinkState(range: getRange, actionBlock: actionBlock)
}
/// Underlines the tappable region and stores the tap logic for interation.
private func setTextLinkState(range: NSRange, actionBlock: @escaping ActionBlock) {
if clauses.isEmpty {
// Replace the last whitespace with \u{00A0} No-break space.
if let start = text?.lastIndex(of: " "), let end = text?.index(after: start) {
text?.replaceSubrange(start..<end, with: "\u{00A0}")
}
}
setActionAttributes(range: range)
appendActionableClause(range: range, actionBlock: actionBlock)
}