By default MGLMapView
puts the scaleBar
view at the top left of the map. I would like to move it to the bottom left, but I am having issues with doing this. Either my NSLayoutConstraint
code is wrong, or something else is happening. The scaleBar
is still stuck on the top left.
Here is what I have tried:
NSMutableArray *scaleBarConstraints = [[NSMutableArray alloc] init];
[self.mapboxMapView removeConstraints:self.mapboxMapView.scaleBar.constraints];
[scaleBarConstraints addObject:
[NSLayoutConstraint constraintWithItem:self.mapboxMapView.scaleBar
attribute:NSLayoutAttributeBottom
relatedBy:NSLayoutRelationGreaterThanOrEqual
toItem:self.mapboxMapView
attribute:NSLayoutAttributeBottom
multiplier:1.0
constant:8.0 + self.mapboxMapView.contentInset.bottom]];
[scaleBarConstraints addObject:
[NSLayoutConstraint constraintWithItem:self.mapboxMapView.scaleBar
attribute:NSLayoutAttributeLeft
relatedBy:NSLayoutRelationEqual
toItem:self.mapboxMapView
attribute:NSLayoutAttributeLeft
multiplier:1.0
constant:8.0 + self.mapboxMapView.contentInset.left]];
[self.mapboxMapView addConstraints:scaleBarConstraints];
Is there another way to do this or have I missed something?