mild changes.

This commit is contained in:
Kevin G Christiano 2019-08-19 12:11:55 -04:00
parent abde89f06f
commit a4bec1d956

View File

@ -238,8 +238,6 @@ public typealias ActionBlock = () -> ()
let range = NSRange(location: location, length: length) let range = NSRange(location: location, length: length)
print(attributeType)
switch attributeType { switch attributeType {
case "underline": case "underline":
attributedString.addAttribute(.underlineStyle, value: NSUnderlineStyle.single.rawValue, range: range) attributedString.addAttribute(.underlineStyle, value: NSUnderlineStyle.single.rawValue, range: range)
@ -581,15 +579,16 @@ extension UITapGestureRecognizer {
return true return true
} }
// Must configure the attributed string to translate what would appear on screen to accurately analyze.
guard let attributedText = label.attributedText else { return false } guard let attributedText = label.attributedText else { return false }
let paragraph = NSMutableParagraphStyle() let paragraph = NSMutableParagraphStyle()
paragraph.alignment = label.textAlignment paragraph.alignment = label.textAlignment
let newAttributedString = NSMutableAttributedString(attributedString: attributedText) let stagedAttributedString = NSMutableAttributedString(attributedString: attributedText)
newAttributedString.addAttributes([NSAttributedString.Key.paragraphStyle: paragraph], range: NSRange(location: 0, length: attributedText.string.count)) stagedAttributedString.addAttributes([NSAttributedString.Key.paragraphStyle: paragraph], range: NSRange(location: 0, length: attributedText.string.count))
let textStorage = NSTextStorage(attributedString: newAttributedString) let textStorage = NSTextStorage(attributedString: stagedAttributedString)
let layoutManager = NSLayoutManager() let layoutManager = NSLayoutManager()
let textContainer = NSTextContainer(size: .zero) let textContainer = NSTextContainer(size: .zero)