From e34f2542589d77c4386b4035aea7107b468d7eb1 Mon Sep 17 00:00:00 2001 From: gia Date: Wed, 19 Nov 2014 13:53:26 +0700 Subject: [PATCH] respect line width when create bar item by shift the x, y half of line width, to prevent it from clipping --- Class/CBStoreHouseRefreshControl.m | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Class/CBStoreHouseRefreshControl.m b/Class/CBStoreHouseRefreshControl.m index f77dcf6..6101f59 100644 --- a/Class/CBStoreHouseRefreshControl.m +++ b/Class/CBStoreHouseRefreshControl.m @@ -97,10 +97,11 @@ + (CBStoreHouseRefreshControl*)attachToScrollView:(UIScrollView *)scrollView CGPoint startPoint = CGPointFromString(startPoints[i]); CGPoint endPoint = CGPointFromString(endPoints[i]); - if (startPoint.x > width) width = startPoint.x; - if (endPoint.x > width) width = endPoint.x; - if (startPoint.y > height) height = startPoint.y; - if (endPoint.y > height) height = endPoint.y; + // shift it base on line width + if (startPoint.x + lineWidth > width) width = startPoint.x + lineWidth; + if (endPoint.x + lineWidth > width) width = endPoint.x + lineWidth; + if (startPoint.y + lineWidth > height) height = startPoint.y + lineWidth; + if (endPoint.y + lineWidth > height) height = endPoint.y + lineWidth; } refreshControl.frame = CGRectMake(0, 0, width, height); @@ -110,6 +111,9 @@ + (CBStoreHouseRefreshControl*)attachToScrollView:(UIScrollView *)scrollView CGPoint startPoint = CGPointFromString(startPoints[i]); CGPoint endPoint = CGPointFromString(endPoints[i]); + // shift it base on line width + startPoint = CGPointMake(startPoint.x + lineWidth/2, startPoint.y + lineWidth/2); + endPoint = CGPointMake(endPoint.x + lineWidth/2, endPoint.y + lineWidth/2); BarItem *barItem = [[BarItem alloc] initWithFrame:refreshControl.frame startPoint:startPoint endPoint:endPoint color:color lineWidth:lineWidth]; barItem.tag = i;