Merge pull request #1091 from marcetcheverry/3.0.0-swift5-NSLinkAttribute

Add support for styling NSLinkAttribute with existing urlAttributes in MessageLabel
This commit is contained in:
Nathan Tannar
2019-07-01 09:27:11 +08:00
committed by GitHub
2 changed files with 7 additions and 0 deletions
+2
View File
@@ -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)
+5
View File
@@ -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)
}