Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[macos] Remove link attribute from attribution text
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
1ec5 committed Apr 11, 2017
1 parent d7f9378 commit 6a0c4e0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
7 changes: 6 additions & 1 deletion platform/darwin/src/MGLAttributionInfo.mm
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,12 @@ @implementation MGLAttributionInfo
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];
}];
Expand Down
2 changes: 1 addition & 1 deletion platform/darwin/test/MGLAttributionInfoTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ - (void)testStyle {
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
Expand Down
1 change: 1 addition & 0 deletions platform/macos/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6a0c4e0

Please sign in to comment.