From 2b7bd49c35ab348d01321e8a4df302f5ad9566e2 Mon Sep 17 00:00:00 2001 From: dmiedema Date: Wed, 11 Feb 2015 22:02:32 -0800 Subject: [PATCH 1/3] Fix Activity Indicator center alignment being shifted left Also fix centered text with no image being shifted right 10 pixels too far --- CRToast/CRToastView.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CRToast/CRToastView.m b/CRToast/CRToastView.m index 7280387d..58391f4a 100644 --- a/CRToast/CRToastView.m +++ b/CRToast/CRToastView.m @@ -77,7 +77,7 @@ static CGFloat CRCenterXForActivityIndicatorWithAlignment(CRToastAccessoryViewAl case CRToastAccessoryViewAlignmentLeft: center = offset; break; case CRToastAccessoryViewAlignmentCenter: - center = (contentWidth / 2) - offset; break; + center = (contentWidth / 2); break; case CRToastAccessoryViewAlignmentRight: center = contentWidth - offset; break; } @@ -140,7 +140,7 @@ - (void)layoutSubviews { 0 : CGRectGetHeight(contentFrame)); - CGFloat imageWidth = imageSize.width == 0 ? kCRStatusBarViewNoImageLeftContentInset : CGRectGetMaxX(_imageView.frame); + CGFloat imageWidth = imageSize.width == 0 ? 0 : CGRectGetMaxX(_imageView.frame); CGFloat x = CRContentXOffsetForViewAlignmentAndWidth(self.toast.imageAlignment, imageWidth); if (self.toast.showActivityIndicator) { From 69ef670cf4694e32d3b7619da31eea8bbb74eb24 Mon Sep 17 00:00:00 2001 From: dmiedema Date: Wed, 11 Feb 2015 22:11:39 -0800 Subject: [PATCH 2/3] Update failing unit test with correct center point --- Tests/Unit Tests/CRToastViewTests.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/Unit Tests/CRToastViewTests.m b/Tests/Unit Tests/CRToastViewTests.m index 2c321eb5..ead2c6f8 100644 --- a/Tests/Unit Tests/CRToastViewTests.m +++ b/Tests/Unit Tests/CRToastViewTests.m @@ -110,7 +110,7 @@ - (void)testActivityFrameCenterAlignment { toast.options = options; self.view.toast = toast; - CGPoint assumedCenter = CGPointMake(100, 50); + CGPoint assumedCenter = CGPointMake(150, 50); [self.view layoutSubviews]; From 5c3ea65b4b73397ef6d941fbeb28dae8f4ee8325 Mon Sep 17 00:00:00 2001 From: dmiedema Date: Wed, 11 Feb 2015 22:29:23 -0800 Subject: [PATCH 3/3] explicitly select center for test, not a created CGPoint --- Tests/Unit Tests/CRToastViewTests.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/Unit Tests/CRToastViewTests.m b/Tests/Unit Tests/CRToastViewTests.m index ead2c6f8..5cafb320 100644 --- a/Tests/Unit Tests/CRToastViewTests.m +++ b/Tests/Unit Tests/CRToastViewTests.m @@ -110,7 +110,7 @@ - (void)testActivityFrameCenterAlignment { toast.options = options; self.view.toast = toast; - CGPoint assumedCenter = CGPointMake(150, 50); + CGPoint assumedCenter = self.view.center; [self.view layoutSubviews];