Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Respect line width when create bar item to prevent clipping #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions Class/CBStoreHouseRefreshControl.m
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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;
Expand Down