for example
let detailLocation = gesture.location(in: contentLabel)
let storage = NSTextStorage(attributedString: contentLabel.attributedText)
let manager = NSLayoutManager()
storage.addLayoutManager(manager)
let container = NSTextContainer(size: CGSize(width: contentLabel.bounds.size.width, height: CGFloat.greatestFiniteMagnitude))
container.lineFragmentPadding = 0
container.maximumNumberOfLines = contentLabel.numberOfLines
container.lineBreakMode = contentLabel.lineBreakMode
manager.addTextContainer(container)
let index = manager.characterIndex(for: detailLocation, in: container, fractionOfDistanceBetweenInsertionPoints: nil)
let attributes = attributedText.attributes(at: index, effectiveRange: nil)
if let attrbuteValue = attributes[CustomAttributedKey] as? String {
print("url is ", attrbuteValue)
}
and other type, at(@xxx) image preview etc.
custome attrbutes interface is needed
for example
and other type, at(@xxx) image preview etc.
custome attrbutes interface is needed