Commit 3753f61d authored by Gauthier Ambard's avatar Gauthier Ambard Committed by Commit Bot

Workaround for iOS 12

This CL changes the layout of the tabCountLabel in the TabGrid button
to position it with autolayout, to prevent the app from freezing when
rotating.

Bug: none
Cq-Include-Trybots: luci.chromium.try:ios-simulator-full-configs;master.tryserver.chromium.mac:ios-simulator-cronet
Change-Id: I104b6c17c336e27301e2c991f0524f2fbf9062c9
Reviewed-on: https://chromium-review.googlesource.com/1136446Reviewed-by: default avatarJustin Cohen <justincohen@chromium.org>
Commit-Queue: Gauthier Ambard <gambard@chromium.org>
Cr-Commit-Position: refs/heads/master@{#574898}
parent 838e1e59
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
#endif #endif
namespace { namespace {
const CGFloat kLabelMargin = 7; const CGFloat kLabelSize = 14;
} // namespace } // namespace
@interface ToolbarTabGridButton () @interface ToolbarTabGridButton ()
...@@ -70,8 +70,12 @@ const CGFloat kLabelMargin = 7; ...@@ -70,8 +70,12 @@ const CGFloat kLabelMargin = 7;
_tabCountLabel = [[UILabel alloc] init]; _tabCountLabel = [[UILabel alloc] init];
[self addSubview:_tabCountLabel]; [self addSubview:_tabCountLabel];
CGRect imageFrame = self.imageView.frame; _tabCountLabel.translatesAutoresizingMaskIntoConstraints = NO;
_tabCountLabel.frame = CGRectInset(imageFrame, kLabelMargin, kLabelMargin); [NSLayoutConstraint activateConstraints:@[
[_tabCountLabel.widthAnchor constraintEqualToConstant:kLabelSize],
[_tabCountLabel.heightAnchor constraintEqualToConstant:kLabelSize],
]];
AddSameCenterConstraints(self, _tabCountLabel);
_tabCountLabel.font = [UIFont systemFontOfSize:kTabGridButtonFontSize _tabCountLabel.font = [UIFont systemFontOfSize:kTabGridButtonFontSize
weight:UIFontWeightBold]; weight:UIFontWeightBold];
...@@ -84,14 +88,4 @@ const CGFloat kLabelMargin = 7; ...@@ -84,14 +88,4 @@ const CGFloat kLabelMargin = 7;
return _tabCountLabel; return _tabCountLabel;
} }
- (void)layoutSubviews {
[super layoutSubviews];
if (!_tabCountLabel)
return;
CGRect imageFrame = self.imageView.frame;
self.tabCountLabel.frame =
CGRectInset(imageFrame, kLabelMargin, kLabelMargin);
}
@end @end
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