Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1331)

Unified Diff: ios/clean/chrome/browser/ui/toolbar/toolbar_button.mm

Issue 2908623004: [ios clean] Toolbar displays total number of tabs. (Closed)
Patch Set: Add comment. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ios/clean/chrome/browser/ui/toolbar/toolbar_button.mm
diff --git a/ios/clean/chrome/browser/ui/toolbar/toolbar_button.mm b/ios/clean/chrome/browser/ui/toolbar/toolbar_button.mm
index a96deea2f2b41e922ee4bcffe0bc3af5ca94b085..4061a75f428a92b6a288aca16e42dba737d2b39e 100644
--- a/ios/clean/chrome/browser/ui/toolbar/toolbar_button.mm
+++ b/ios/clean/chrome/browser/ui/toolbar/toolbar_button.mm
@@ -4,6 +4,8 @@
#import "ios/clean/chrome/browser/ui/toolbar/toolbar_button.h"
+#import "ios/chrome/browser/ui/uikit_ui_util.h"
+
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
@@ -20,10 +22,25 @@
[button setImage:normalImage forState:UIControlStateNormal];
[button setImage:highlightedImage forState:UIControlStateHighlighted];
[button setImage:disabledImage forState:UIControlStateDisabled];
+ button.titleLabel.textAlignment = NSTextAlignmentCenter;
button.translatesAutoresizingMaskIntoConstraints = NO;
return button;
}
+- (void)layoutSubviews {
+ [super layoutSubviews];
+ // If the UIButton title has text it will center it on top of the image,
+ // this is currently used for the TabStripButton which displays the
+ // total number of tabs.
+ if (self.titleLabel.text) {
+ CGSize size = self.bounds.size;
+ CGPoint center = CGPointMake(size.width / 2, size.height / 2);
+ self.imageView.center = center;
+ self.imageView.frame = AlignRectToPixel(self.imageView.frame);
+ self.titleLabel.frame = self.bounds;
+ }
+}
+
#pragma mark - Public Methods
- (void)updateHiddenInCurrentSizeClass {
« no previous file with comments | « ios/clean/chrome/browser/ui/toolbar/BUILD.gn ('k') | ios/clean/chrome/browser/ui/toolbar/toolbar_constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698