summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabian Guerra <fabian.guerra@mapbox.com>2018-01-10 11:22:45 -0600
committerFabian Guerra <fabian.guerra@mapbox.com>2018-01-10 11:22:45 -0600
commit6ac53991e6d06b90e2aa7b0e8c4ce3ec67b788f0 (patch)
tree2bb132872f23e82f1f0baf595acf28cd7333f4f2
parent48db3410b9c0294eb546c992a78ac9d92ac45cac (diff)
downloadqtlocation-mapboxgl-6ac53991e6d06b90e2aa7b0e8c4ce3ec67b788f0.tar.gz
[ios] Refactor MGLMapView ornaments layout constraints for iOS 11.
-rw-r--r--platform/ios/src/MGLMapView.mm31
1 files changed, 15 insertions, 16 deletions
diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm
index 0337fbe3ef..579dac3a38 100644
--- a/platform/ios/src/MGLMapView.mm
+++ b/platform/ios/src/MGLMapView.mm
@@ -892,10 +892,7 @@ public:
// compass view
[self removeConstraints:self.compassViewConstraints];
[self.compassViewConstraints removeAllObjects];
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wpartial-availability"
- [self.compassViewConstraints addObject:[self.compassView.topAnchor constraintEqualToSystemSpacingBelowAnchor:safeAreaLayoutGuide.topAnchor multiplier:1]];
-#pragma clang diagnostic pop
+ [self.compassViewConstraints addObject:[self constraintForYAxisAnchor:self.compassView.topAnchor belowAnchor:safeAreaLayoutGuide.topAnchor]];
[self.compassViewConstraints addObject:[safeAreaLayoutGuide.rightAnchor constraintEqualToAnchor:self.compassView.rightAnchor
constant:8.0 + self.contentInset.right]];
[self addConstraints:self.compassViewConstraints];
@@ -903,10 +900,7 @@ public:
// scale bar view
[self removeConstraints:self.scaleBarConstraints];
[self.scaleBarConstraints removeAllObjects];
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wpartial-availability"
- [self.scaleBarConstraints addObject:[self.scaleBar.topAnchor constraintEqualToSystemSpacingBelowAnchor:safeAreaLayoutGuide.topAnchor multiplier:1]];
-#pragma clang diagnostic pop
+ [self.scaleBarConstraints addObject:[self constraintForYAxisAnchor:self.scaleBar.topAnchor belowAnchor:safeAreaLayoutGuide.topAnchor]];
[self.scaleBarConstraints addObject:[self.scaleBar.leftAnchor constraintEqualToAnchor:safeAreaLayoutGuide.leftAnchor
constant:8.0 + self.contentInset.left]];
[self addConstraints:self.scaleBarConstraints];
@@ -914,10 +908,8 @@ public:
// logo view
[self removeConstraints:self.logoViewConstraints];
[self.logoViewConstraints removeAllObjects];
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wpartial-availability"
- [NSLayoutConstraint activateConstraints:@[[safeAreaLayoutGuide.bottomAnchor constraintEqualToSystemSpacingBelowAnchor:self.logoView.bottomAnchor multiplier:1.0]]];
-#pragma clang diagnostic pop
+// [NSLayoutConstraint activateConstraints:@[[self constraintForYAxisAnchor:safeAreaLayoutGuide.bottomAnchor belowAnchor:self.logoView.bottomAnchor]]];
+ [self.logoViewConstraints addObject:[self constraintForYAxisAnchor:safeAreaLayoutGuide.bottomAnchor belowAnchor:self.logoView.bottomAnchor]];
[self.logoViewConstraints addObject:[self.logoView.leftAnchor constraintEqualToAnchor:safeAreaLayoutGuide.leftAnchor
constant:8.0 + self.contentInset.left]];
[self addConstraints:self.logoViewConstraints];
@@ -925,10 +917,8 @@ public:
// attribution button
[self removeConstraints:self.attributionButtonConstraints];
[self.attributionButtonConstraints removeAllObjects];
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wpartial-availability"
- [NSLayoutConstraint activateConstraints:@[[safeAreaLayoutGuide.bottomAnchor constraintEqualToSystemSpacingBelowAnchor:self.attributionButton.bottomAnchor multiplier:1.0]]];
-#pragma clang diagnostic pop
+// [NSLayoutConstraint activateConstraints:@[[self constraintForYAxisAnchor:safeAreaLayoutGuide.bottomAnchor belowAnchor:self.attributionButton.bottomAnchor]]];
+ [self.attributionButtonConstraints addObject:[self constraintForYAxisAnchor:safeAreaLayoutGuide.bottomAnchor belowAnchor:self.attributionButton.bottomAnchor]];
[self.attributionButtonConstraints addObject:[safeAreaLayoutGuide.rightAnchor constraintEqualToAnchor:self.attributionButton.rightAnchor
constant:8.0 + self.contentInset.right]];
[self addConstraints:self.attributionButtonConstraints];
@@ -942,6 +932,15 @@ public:
[super updateConstraints];
}
+- (NSLayoutConstraint *)constraintForYAxisAnchor:(NSLayoutYAxisAnchor *)yAxisAnchor belowAnchor:(NSLayoutYAxisAnchor *)anchor
+{
+ if (@available(iOS 11.0, *)) {
+ return [yAxisAnchor constraintEqualToSystemSpacingBelowAnchor:anchor multiplier:1];
+ } else {
+ return nil;
+ }
+}
+
- (BOOL)isOpaque
{
return _opaque;