summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMinh Nguyễn <mxn@1ec5.org>2017-04-10 14:56:25 -0700
committerMinh Nguyễn <mxn@1ec5.org>2017-04-10 22:06:36 -0700
commit6a0c4e0142ef44d7c9f3f05e9a7ddfed985809ad (patch)
treefd1754cf3585890d8647cca9e3eadf7c9cb0c3bf
parentd7f9378bca4bb6b4a6b3871b0e42961cae6a847b (diff)
downloadqtlocation-mapboxgl-6a0c4e0142ef44d7c9f3f05e9a7ddfed985809ad.tar.gz
[macos] Remove link attribute from attribution text
Fixed an issue causing the attribution button text to appear blue instead of black. On macOS 10.12 and above, hyperlinks in attributed strings are blue regardless of any color attributes applied to the same run of text.
-rw-r--r--platform/darwin/src/MGLAttributionInfo.mm7
-rw-r--r--platform/darwin/test/MGLAttributionInfoTests.m2
-rw-r--r--platform/macos/CHANGELOG.md1
3 files changed, 8 insertions, 2 deletions
diff --git a/platform/darwin/src/MGLAttributionInfo.mm b/platform/darwin/src/MGLAttributionInfo.mm
index fa2ae787a5..7583244491 100644
--- a/platform/darwin/src/MGLAttributionInfo.mm
+++ b/platform/darwin/src/MGLAttributionInfo.mm
@@ -93,7 +93,12 @@
return;
}
- MGLAttributionInfo *info = [[MGLAttributionInfo alloc] initWithTitle:title URL:value];
+ // Remove the link, because it forces the text to be blue on macOS 10.12
+ // and above.
+ NSMutableAttributedString *unlinkedTitle = [title mutableCopy];
+ [unlinkedTitle removeAttribute:NSLinkAttributeName range:unlinkedTitle.mgl_wholeRange];
+
+ MGLAttributionInfo *info = [[MGLAttributionInfo alloc] initWithTitle:unlinkedTitle URL:value];
info.feedbackLink = isFeedbackLink;
[infos addObject:info];
}];
diff --git a/platform/darwin/test/MGLAttributionInfoTests.m b/platform/darwin/test/MGLAttributionInfoTests.m
index 74859bda82..e258671c09 100644
--- a/platform/darwin/test/MGLAttributionInfoTests.m
+++ b/platform/darwin/test/MGLAttributionInfoTests.m
@@ -68,7 +68,7 @@
XCTAssertEqual(infos.count, 1);
XCTAssertEqualObjects(infos[0].title.string, @"Mapbox");
- XCTAssertEqualObjects([infos[0].title attribute:NSLinkAttributeName atIndex:0 effectiveRange:nil], [NSURL URLWithString:@"https://www.mapbox.com/"]);
+ XCTAssertNil([infos[0].title attribute:NSLinkAttributeName atIndex:0 effectiveRange:nil]);
XCTAssertEqualObjects([infos[0].title attribute:NSUnderlineStyleAttributeName atIndex:0 effectiveRange:nil], @(NSUnderlineStyleSingle));
#if TARGET_OS_IPHONE
diff --git a/platform/macos/CHANGELOG.md b/platform/macos/CHANGELOG.md
index 152fdc382b..dab02592a5 100644
--- a/platform/macos/CHANGELOG.md
+++ b/platform/macos/CHANGELOG.md
@@ -2,6 +2,7 @@
## master
+* Fixed an issue causing attribution button text to appear blue instead of black. ([#8701](https://github.com/mapbox/mapbox-gl-native/pull/8701))
* The error passed into `-[MGLMapViewDelegate mapViewDidFailLoadingMap:withError:]` now includes a more specific description and failure reason. ([#8418](https://github.com/mapbox/mapbox-gl-native/pull/8418))
## 0.4.0