Commit b472bbd6 authored by Jean-François Geyelin's avatar Jean-François Geyelin Committed by Commit Bot

Have the toolbar's KAV respect the safeAreaLayoutGuide on iOS11.

Bug: 764692
Change-Id: I3e2493f770e8218aa9a5eb0351dfc0db0612832d
Reviewed-on: https://chromium-review.googlesource.com/664809
Commit-Queue: Jean-François Geyelin <jif@chromium.org>
Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Cr-Commit-Position: refs/heads/master@{#501638}
parent a43ad218
...@@ -88,6 +88,19 @@ ...@@ -88,6 +88,19 @@
[self addSubview:searchStackView]; [self addSubview:searchStackView];
// Position the stack views. // Position the stack views.
if (@available(iOS 11, *)) {
UILayoutGuide* layoutGuide = self.safeAreaLayoutGuide;
[NSLayoutConstraint activateConstraints:@[
[searchStackView.leadingAnchor
constraintEqualToAnchor:layoutGuide.leadingAnchor
constant:kHorizontalMargin],
[shortcutStackView.trailingAnchor
constraintEqualToAnchor:layoutGuide.trailingAnchor
constant:-kHorizontalMargin],
[searchStackView.trailingAnchor
constraintLessThanOrEqualToAnchor:shortcutStackView.leadingAnchor]
]];
} else {
NSArray* constraints = @[ NSArray* constraints = @[
@"H:|-horizontalMargin-[searchStackView]-(>=0)-[shortcutStackView]", @"H:|-horizontalMargin-[searchStackView]-(>=0)-[shortcutStackView]",
@"[shortcutStackView]-horizontalMargin-|", @"[shortcutStackView]-horizontalMargin-|",
...@@ -100,6 +113,7 @@ ...@@ -100,6 +113,7 @@
@"horizontalMargin" : @(kHorizontalMargin), @"horizontalMargin" : @(kHorizontalMargin),
}; };
ApplyVisualConstraintsWithMetrics(constraints, viewsDictionary, metrics); ApplyVisualConstraintsWithMetrics(constraints, viewsDictionary, metrics);
}
AddSameCenterYConstraint(searchStackView, self); AddSameCenterYConstraint(searchStackView, self);
AddSameCenterYConstraint(shortcutStackView, self); AddSameCenterYConstraint(shortcutStackView, self);
} }
...@@ -135,6 +149,17 @@ ...@@ -135,6 +149,17 @@
return YES; return YES;
} }
- (void)layoutMarginsDidChange {
NSLog(@"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$");
NSLog(@"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$");
NSLog(@"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$");
NSLog(@"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$");
NSLog(@"%i", self.preservesSuperviewLayoutMargins);
NSLog(@"%f %f", self.layoutMargins.left, self.layoutMargins.right);
[super layoutMarginsDidChange];
}
- (void)keyboardButtonPressed:(id)sender { - (void)keyboardButtonPressed:(id)sender {
UIButton* button = base::mac::ObjCCastStrict<UIButton>(sender); UIButton* button = base::mac::ObjCCastStrict<UIButton>(sender);
[[UIDevice currentDevice] playInputClick]; [[UIDevice currentDevice] playInputClick];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment