diff --git a/CHANGELOG.md b/CHANGELOG.md index cbe6a90b..22d4e523 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ The changelog for `MessageKit`. Also see the [releases](https://github.com/Messa ### Added +- Add support for styling NSLinkAttribute with existing urlAttributes in MessageLabel. [#1091](https://github.com/MessageKit/MessageKit/pull/1091) by [@marcetcheverry](https://github.com/marcetcheverry) + - Add loading indicator to AudioMessageCell. [#1084](https://github.com/MessageKit/MessageKit/pull/1084) by [@marcetcheverry](https://github.com/marcetcheverry) - Lazily initialize the MessageInputBar on MessagesViewController. [#1092](https://github.com/MessageKit/MessageKit/pull/1092) by [@marcetcheverry](https://github.com/marcetcheverry) diff --git a/Sources/Views/MessageLabel.swift b/Sources/Views/MessageLabel.swift index 3ea89490..90a78c05 100644 --- a/Sources/Views/MessageLabel.swift +++ b/Sources/Views/MessageLabel.swift @@ -273,6 +273,11 @@ open class MessageLabel: UILabel { guard let rangeTuples = rangesForDetectors[detector] else { continue } for (range, _) in rangeTuples { + // This will enable us to attribute it with our own styles, since `UILabel` does not provide link attribute overrides like `UITextView` does + if detector.textCheckingType == .link { + mutableAttributedString.removeAttribute(NSAttributedString.Key.link, range: range) + } + let attributes = detectorAttributes(for: detector) mutableAttributedString.addAttributes(attributes, range: range) }