[ios] Fix the layout constraints on iOS 11 for iPhone X (#10858)
* [ios] Fix the layout constraints on iOS 11 for iPhone X for the bottom ornaments. * WIP adding tests for layout of map view attribution logo and other ornaments * Rename * First pass at tests for mapview ornament layout * Additional code changes from call with Fabian and Jason * [ios] Fix ornaments insets margin space. * [ios] Fix map view layout test for pre iOS 11. * [ios] Refactor MGLMapView ornaments layout constraints for iOS 11. * [ios] Remove NSLogs from MGLMapViewLayoutTests
This commit is contained in:
committed by
GitHub
parent
a3c497f100
commit
0542ece0bf
@@ -753,7 +753,7 @@ public:
|
||||
toItem:viewController.topLayoutGuide
|
||||
attribute:NSLayoutAttributeBottom
|
||||
multiplier:1.0
|
||||
constant:5.0]];
|
||||
constant:8.0]];
|
||||
}
|
||||
[self.compassViewConstraints addObject:
|
||||
[NSLayoutConstraint constraintWithItem:self.compassView
|
||||
@@ -762,7 +762,7 @@ public:
|
||||
toItem:self
|
||||
attribute:NSLayoutAttributeTop
|
||||
multiplier:1.0
|
||||
constant:5.0 + self.contentInset.top]];
|
||||
constant:8.0 + self.contentInset.top]];
|
||||
|
||||
[self.compassViewConstraints addObject:
|
||||
[NSLayoutConstraint constraintWithItem:self
|
||||
@@ -771,7 +771,7 @@ public:
|
||||
toItem:self.compassView
|
||||
attribute:NSLayoutAttributeTrailing
|
||||
multiplier:1.0
|
||||
constant:5.0 + self.contentInset.right]];
|
||||
constant:8.0 + self.contentInset.right]];
|
||||
|
||||
[containerView addConstraints:self.compassViewConstraints];
|
||||
|
||||
@@ -788,7 +788,7 @@ public:
|
||||
toItem:viewController.topLayoutGuide
|
||||
attribute:NSLayoutAttributeBottom
|
||||
multiplier:1.0
|
||||
constant:5.0]];
|
||||
constant:8.0]];
|
||||
}
|
||||
[self.scaleBarConstraints addObject:
|
||||
[NSLayoutConstraint constraintWithItem:self.scaleBar
|
||||
@@ -797,7 +797,7 @@ public:
|
||||
toItem:self
|
||||
attribute:NSLayoutAttributeTop
|
||||
multiplier:1.0
|
||||
constant:5.0 + self.contentInset.top]];
|
||||
constant:8.0 + self.contentInset.top]];
|
||||
[self.scaleBarConstraints addObject:
|
||||
[NSLayoutConstraint constraintWithItem:self.scaleBar
|
||||
attribute:NSLayoutAttributeLeft
|
||||
@@ -831,7 +831,7 @@ public:
|
||||
toItem:self.logoView
|
||||
attribute:NSLayoutAttributeBaseline
|
||||
multiplier:1
|
||||
constant:8 + self.contentInset.bottom]];
|
||||
constant:8.0 + self.contentInset.bottom]];
|
||||
[self.logoViewConstraints addObject:
|
||||
[NSLayoutConstraint constraintWithItem:self.logoView
|
||||
attribute:NSLayoutAttributeLeading
|
||||
@@ -855,7 +855,7 @@ public:
|
||||
toItem:self.attributionButton
|
||||
attribute:NSLayoutAttributeBaseline
|
||||
multiplier:1
|
||||
constant:8 + self.contentInset.bottom]];
|
||||
constant:8.0 + self.contentInset.bottom]];
|
||||
}
|
||||
[self.attributionButtonConstraints addObject:
|
||||
[NSLayoutConstraint constraintWithItem:self
|
||||
@@ -864,7 +864,7 @@ public:
|
||||
toItem:self.attributionButton
|
||||
attribute:NSLayoutAttributeBaseline
|
||||
multiplier:1
|
||||
constant:8 + self.contentInset.bottom]];
|
||||
constant:8.0 + self.contentInset.bottom]];
|
||||
|
||||
[self.attributionButtonConstraints addObject:
|
||||
[NSLayoutConstraint constraintWithItem:self
|
||||
@@ -873,29 +873,20 @@ public:
|
||||
toItem:self.attributionButton
|
||||
attribute:NSLayoutAttributeTrailing
|
||||
multiplier:1
|
||||
constant:8 + self.contentInset.right]];
|
||||
constant:8.0 + self.contentInset.right]];
|
||||
[containerView addConstraints:self.attributionButtonConstraints];
|
||||
}
|
||||
|
||||
- (void)updateConstraints
|
||||
{
|
||||
|
||||
// If compiling with the iOS 11+ SDK
|
||||
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000
|
||||
// If safeAreaLayoutGuide API exists
|
||||
if ( [self respondsToSelector:@selector(safeAreaLayoutGuide)] ) {
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wpartial-availability"
|
||||
if (@available(iOS 11.0, *)) {
|
||||
UILayoutGuide *safeAreaLayoutGuide = self.safeAreaLayoutGuide;
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
// 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 +894,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,8 +902,7 @@ public:
|
||||
// logo view
|
||||
[self removeConstraints:self.logoViewConstraints];
|
||||
[self.logoViewConstraints removeAllObjects];
|
||||
[self.logoViewConstraints addObject:[safeAreaLayoutGuide.bottomAnchor constraintEqualToAnchor:self.logoView.bottomAnchor
|
||||
constant:8.0 + self.contentInset.bottom]];
|
||||
[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];
|
||||
@@ -923,21 +910,26 @@ public:
|
||||
// attribution button
|
||||
[self removeConstraints:self.attributionButtonConstraints];
|
||||
[self.attributionButtonConstraints removeAllObjects];
|
||||
[self.attributionButtonConstraints addObject:[safeAreaLayoutGuide.bottomAnchor constraintEqualToAnchor:self.attributionButton.bottomAnchor
|
||||
constant:8.0 + self.contentInset.bottom]];
|
||||
[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];
|
||||
} else {
|
||||
[self updateConstraintsPreiOS11];
|
||||
}
|
||||
#else
|
||||
[self updateConstraintsPreiOS11];
|
||||
#endif
|
||||
|
||||
[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;
|
||||
|
||||
Reference in New Issue
Block a user