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

Commit

Permalink
[ios] animate scale bar
Browse files Browse the repository at this point in the history
  • Loading branch information
frederoni committed Apr 13, 2017
1 parent 724cda5 commit c6fa267
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 2 additions & 0 deletions platform/ios/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ Mapbox welcomes participation and contributions from everyone. Please read [CONT

## master

* Added a scale bar to MGLMapView that indicates the scale of the map. ([#7631](https://github.com/mapbox/mapbox-gl-native/pull/7631))

### Styles

* MGLSymbolStyleLayer’s `iconImageName`, `iconScale`, `textFontSize`, `textOffset`, and `textRotation` properties can now be set to a source or composite function. ([#8544](https://github.com/mapbox/mapbox-gl-native/pull/8544), [#8590](https://github.com/mapbox/mapbox-gl-native/pull/8590), [#8592](https://github.com/mapbox/mapbox-gl-native/pull/8592), [#8593](https://github.com/mapbox/mapbox-gl-native/pull/8593))
Expand Down
2 changes: 1 addition & 1 deletion platform/ios/src/MGLMapView.h
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ IB_DESIGNABLE

/**
A control indicating the scale of the map. The scale bar is positioned in the
upper-left corner.
upper-left corner. The scale bar is hidden by default.
*/
@property (nonatomic, readonly) UIView *scaleBar;

Expand Down
8 changes: 7 additions & 1 deletion platform/ios/src/MGLScaleBar.mm
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,13 @@ - (void)updateVisibility {
? MGLMetricTable[count-1].distance
: MGLImperialTable[count-1].distance;

self.alpha = maximumDistance > allowedDistance ? 0 : 1;
CGFloat alpha = maximumDistance > allowedDistance ? .0f : 1.0f;

if(self.alpha != alpha) {
[UIView animateWithDuration:.2f delay:0 options:UIViewAnimationOptionBeginFromCurrentState animations:^{
self.alpha = alpha;
} completion:nil];
}
}

- (void)setRow:(MGLRow)row {
Expand Down

0 comments on commit c6fa267

Please sign in to comment.