Open DingSoung opened 5 years ago
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
I'm not quite sure I understand what you want in a custom attributes interface. Could you give me a more detailed description of what you are showing me in that example @DingSoung
for example
and other type, at(@xxx) image preview etc.
custome attrbutes interface is needed