diff options
author | Julian Rex <julian.rex@gmail.com> | 2019-02-05 13:50:12 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-02-05 13:50:12 -0500 |
commit | 5ba4a6a980119010fba6515a14d3a67a73dd4672 (patch) | |
tree | 875553d90445741c91e45f1f7aa89dd0aa9a7d84 /platform/ios/src/MGLScaleBar.mm | |
parent | 47852b6c42b7884dbb7ad107a112c7e0d9f96ed0 (diff) | |
download | qtlocation-mapboxgl-5ba4a6a980119010fba6515a14d3a67a73dd4672.tar.gz |
[ios] Reverts "Enable customize positions of mapview ornaments (#13556)" (#13870)
This reverts commit e22d28c285c1543ebbf75d205f0129e74b0fbb8a.
Diffstat (limited to 'platform/ios/src/MGLScaleBar.mm')
-rw-r--r-- | platform/ios/src/MGLScaleBar.mm | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/platform/ios/src/MGLScaleBar.mm b/platform/ios/src/MGLScaleBar.mm index caa5157a49..f17d7b7ad2 100644 --- a/platform/ios/src/MGLScaleBar.mm +++ b/platform/ios/src/MGLScaleBar.mm @@ -86,7 +86,7 @@ static const MGLRow MGLImperialTable[] ={ @property (nonatomic, assign) CGFloat borderWidth; @property (nonatomic) NSCache* labelImageCache; @property (nonatomic) MGLScaleBarLabel* prototypeLabel; -@property (nonatomic) CGFloat lastLabelWidth; + @end @@ -94,7 +94,6 @@ static const CGFloat MGLBarHeight = 4; static const CGFloat MGLFeetPerMeter = 3.28084; @interface MGLScaleBarLabel : UILabel - @end @implementation MGLScaleBarLabel @@ -185,7 +184,7 @@ static const CGFloat MGLFeetPerMeter = 3.28084; #pragma mark - Dimensions - (CGSize)intrinsicContentSize { - return CGSizeMake(self.actualWidth + self.lastLabelWidth/2, 16); + return CGSizeMake(self.actualWidth, 16); } - (CGFloat)actualWidth { @@ -195,7 +194,8 @@ static const CGFloat MGLFeetPerMeter = 3.28084; - (CGFloat)maximumWidth { CGFloat fullWidth = CGRectGetWidth(self.superview.bounds); - return floorf(fullWidth / 2); + CGFloat padding = [self usesRightToLeftLayout] ? fullWidth - CGRectGetMaxX(self.frame) : CGRectGetMinX(self.frame); + return floorf(fullWidth / 2 - padding); } - (CGFloat)unitsPerPoint { @@ -256,9 +256,12 @@ static const CGFloat MGLFeetPerMeter = 3.28084; [self updateVisibility]; self.row = [self preferredRow]; - + CGSize size = self.intrinsicContentSize; - self.bounds = CGRectMake(0, 0, size.width, size.height); + self.frame = CGRectMake(CGRectGetMinX(self.frame), + CGRectGetMinY(self.frame), + size.width, + size.height); } - (void)updateVisibility { @@ -368,9 +371,7 @@ static const CGFloat MGLFeetPerMeter = 3.28084; CLLocationDistance barDistance = multiplier * i; UIImage *image = [self cachedLabelImageForDistance:barDistance]; - if (i == self.row.numberOfBars) { - self.lastLabelWidth = image.size.width; - } + labelView.layer.contents = (id)image.CGImage; labelView.layer.contentsScale = image.scale; } @@ -420,7 +421,7 @@ static const CGFloat MGLFeetPerMeter = 3.28084; } - (void)layoutLabels { - CGFloat barWidth = round(self.actualWidth / self.bars.count); + CGFloat barWidth = round(self.bounds.size.width / self.bars.count); BOOL RTL = [self usesRightToLeftLayout]; NSUInteger i = RTL ? self.bars.count : 0; for (UIView *label in self.labelViews) { |