I have one text (ASTextNode)
let contentNode = ASTextNode()
contentNode.maximumNumberOfLines = 7
contentNode.truncationMode = .byTruncatingTail
contentNode.isUserInteractionEnabled = true
contentNode.delegate = self
and in contentNode have link
I setup touchUpInSide for contentNode
contentNode.addTarget(self, action: #selector(contentNodeTapped), forControlEvents: .touchUpInside)
@objc func contentNodeTapped() {
if contentNode.maximumNumberOfLines == 7 {
contentNode.maximumNumberOfLines = 0
} else {
contentNode.maximumNumberOfLines = 7
}
UIView.animate(withDuration: 0.2, delay: 0, options: [UIView.AnimationOptions.layoutSubviews], animations: {
self.contentNode.setNeedsLayout()
self.contentNode.layoutIfNeeded()
}, completion: nil)
}
func textNode(_ textNode: ASTextNode!, tappedLinkAttribute attribute: String!, value: Any!, at point: CGPoint, textRange: NSRange) {
guard let url = value as? URL else { return }
UIApplication.shared.open(url, options: [:], completionHandler: nil)
}
when i tapped to contentNode i want to change maximumNumberOfLines to see all text, but it's not smooth. I just try UIView.animate but it's not effect.
And when i tapped to link in contentNode, it't call both 2 function contentNodeTapped
and tappedLinkAttribute
.
How to when tapped link only call tappedLinkAttribute
.
Text after tapped