From cf91becd03fecd08c599ec2ad4f28b8f58b25c0e Mon Sep 17 00:00:00 2001 From: AJ Ballway Date: Tue, 31 Jan 2017 12:19:35 -0800 Subject: [PATCH 1/4] Remove EbrCenterTextInRectVertically --- Frameworks/UIKit/UITabBarButton.mm | 9 +++------ Frameworks/UIKit/UITextView.mm | 9 --------- 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/Frameworks/UIKit/UITabBarButton.mm b/Frameworks/UIKit/UITabBarButton.mm index bdee60b251..b633a24ca6 100644 --- a/Frameworks/UIKit/UITabBarButton.mm +++ b/Frameworks/UIKit/UITabBarButton.mm @@ -126,15 +126,12 @@ - (void)drawRect:(CGRect)pos { id font = [UIFont defaultFont]; size = [title sizeWithFont:font constrainedToSize:CGSizeMake(0.0f, 0.0f) lineBreakMode:UILineBreakModeClip]; - CGRect textRect; - textRect.origin.y = rect.size.height - size.height; + CGRect textRect{}; + textRect.origin.y = (rect.size.height - size.height) / 2.0; textRect.origin.x = rect.origin.x; textRect.size.width = rect.size.width; textRect.size.height = size.height; - // TODO(DH) - // EbrCenterTextInRectVertically(&textRect, &size, font); - - CGContextSetFillColorWithColor(context, (CGColorRef)[UIColor whiteColor]); + CGContextSetFillColorWithColor(context, CGColorGetConstantColor(kCGColorWhite)); size = [title drawInRect:textRect withFont:font lineBreakMode:UILineBreakModeClip alignment:UITextAlignmentCenter]; } } diff --git a/Frameworks/UIKit/UITextView.mm b/Frameworks/UIKit/UITextView.mm index 86bb6ad140..db5d1c7565 100644 --- a/Frameworks/UIKit/UITextView.mm +++ b/Frameworks/UIKit/UITextView.mm @@ -757,15 +757,6 @@ - (CGSize)sizeThatFits:(CGSize)fitSize { CGSize fontExtent = { 0, 0 }; fontExtent = [[self _text] sizeWithFont:(id)_font forWidth:rect.size.width lineBreakMode:UILineBreakModeWordWrap]; - - CGRect centerRect; - centerRect.origin.x = 0; - centerRect.origin.y = 0; - centerRect.size = fontExtent; - // TODO(DH) - // EbrCenterTextInRectVertically(¢erRect, &fontExtent, _font); - rect.origin.y += centerRect.origin.y; - ret.width = ourRect.size.width; ret.height = fontExtent.height + _marginSize * 2.0f; From 8586f0a3d6daa963ef4bc974a960aaeeed6298e3 Mon Sep 17 00:00:00 2001 From: AJ Ballway Date: Tue, 31 Jan 2017 14:59:52 -0800 Subject: [PATCH 2/4] Add a comment --- Frameworks/UIKit/UITabBarButton.mm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Frameworks/UIKit/UITabBarButton.mm b/Frameworks/UIKit/UITabBarButton.mm index b633a24ca6..2836910782 100644 --- a/Frameworks/UIKit/UITabBarButton.mm +++ b/Frameworks/UIKit/UITabBarButton.mm @@ -127,6 +127,8 @@ - (void)drawRect:(CGRect)pos { size = [title sizeWithFont:font constrainedToSize:CGSizeMake(0.0f, 0.0f) lineBreakMode:UILineBreakModeClip]; CGRect textRect{}; + + // Horizontally center text textRect.origin.y = (rect.size.height - size.height) / 2.0; textRect.origin.x = rect.origin.x; textRect.size.width = rect.size.width; From ec20c0c9bd0bbee6ab56578e269fa742553468c4 Mon Sep 17 00:00:00 2001 From: AJ Ballway Date: Tue, 31 Jan 2017 15:07:19 -0800 Subject: [PATCH 3/4] directions are hard --- Frameworks/UIKit/UITabBarButton.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Frameworks/UIKit/UITabBarButton.mm b/Frameworks/UIKit/UITabBarButton.mm index 2836910782..0995e7eed0 100644 --- a/Frameworks/UIKit/UITabBarButton.mm +++ b/Frameworks/UIKit/UITabBarButton.mm @@ -128,7 +128,7 @@ - (void)drawRect:(CGRect)pos { CGRect textRect{}; - // Horizontally center text + // Vertically center text textRect.origin.y = (rect.size.height - size.height) / 2.0; textRect.origin.x = rect.origin.x; textRect.size.width = rect.size.width; From ae59edaa18107e0b9d7b4a772972bc4f13f3952e Mon Sep 17 00:00:00 2001 From: AJ Ballway Date: Wed, 1 Feb 2017 08:58:52 -0800 Subject: [PATCH 4/4] do it right --- Frameworks/UIKit/UITabBarButton.mm | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/Frameworks/UIKit/UITabBarButton.mm b/Frameworks/UIKit/UITabBarButton.mm index 0995e7eed0..a427c58ced 100644 --- a/Frameworks/UIKit/UITabBarButton.mm +++ b/Frameworks/UIKit/UITabBarButton.mm @@ -126,13 +126,8 @@ - (void)drawRect:(CGRect)pos { id font = [UIFont defaultFont]; size = [title sizeWithFont:font constrainedToSize:CGSizeMake(0.0f, 0.0f) lineBreakMode:UILineBreakModeClip]; - CGRect textRect{}; - // Vertically center text - textRect.origin.y = (rect.size.height - size.height) / 2.0; - textRect.origin.x = rect.origin.x; - textRect.size.width = rect.size.width; - textRect.size.height = size.height; + CGRect textRect = CGRectMake((rect.size.height - size.height) / 2.0, rect.origin.x, rect.size.width, size.height); CGContextSetFillColorWithColor(context, CGColorGetConstantColor(kCGColorWhite)); size = [title drawInRect:textRect withFont:font lineBreakMode:UILineBreakModeClip alignment:UITextAlignmentCenter]; }