[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.
This commit is contained in:
Minh Nguyễn
2017-04-10 14:56:25 -07:00
committed by Minh Nguyễn
parent d7f9378bca
commit 6a0c4e0142
3 changed files with 8 additions and 2 deletions

View File

@@ -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];
}];

View File

@@ -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

View File

@@ -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