Skip to content

Commit

Permalink
Bugfix CGRect of titleFrame
Browse files Browse the repository at this point in the history
When updating the subTitle, at the beginning the subTitleLabel.text is empty.

It should be filled before setting the frame Rects, if not the labels will overlay.
  • Loading branch information
brokedi committed Feb 14, 2013
1 parent 36c3270 commit b36a9bc
Showing 1 changed file with 18 additions and 20 deletions.
38 changes: 18 additions & 20 deletions SVPullToRefresh/UIScrollView+SVPullToRefresh.m
Original file line number Diff line number Diff line change
Expand Up @@ -173,23 +173,7 @@ - (void)willMoveToSuperview:(UIView *)newSuperview {
}

- (void)layoutSubviews {
CGFloat remainingWidth = self.superview.bounds.size.width-200;
float position = 0.50;

CGRect titleFrame = self.titleLabel.frame;
titleFrame.origin.x = ceilf(remainingWidth*position+44);
titleFrame.origin.y = self.bounds.size.height-(self.subtitleLabel.text ? 48 : 40);
self.titleLabel.frame = titleFrame;

CGRect subtitleFrame = self.subtitleLabel.frame;
subtitleFrame.origin.x = titleFrame.origin.x;
subtitleFrame.origin.y = self.bounds.size.height-32;
self.subtitleLabel.frame = subtitleFrame;

CGRect arrowFrame = self.arrow.frame;
arrowFrame.origin.x = ceilf(remainingWidth*position);
self.arrow.frame = arrowFrame;

self.activityIndicatorView.center = self.arrow.center;

for(id otherView in self.viewForState) {
Expand All @@ -205,10 +189,6 @@ - (void)layoutSubviews {
self.arrow.hidden = hasCustomView;

if(hasCustomView) {
for (UIView *subview in self.subviews) {
[subview removeFromSuperview];
}

[self addSubview:customView];
CGRect viewBounds = [customView bounds];
CGPoint origin = CGPointMake(roundf((self.bounds.size.width-viewBounds.size.width)/2), roundf((self.bounds.size.height-viewBounds.size.height)/2));
Expand Down Expand Up @@ -238,6 +218,24 @@ - (void)layoutSubviews {
break;
}
}

CGFloat remainingWidth = self.superview.bounds.size.width-200;
float position = 0.50;

CGRect titleFrame = self.titleLabel.frame;
titleFrame.origin.x = ceilf(remainingWidth*position+44);
titleFrame.origin.y = self.bounds.size.height-(self.subtitleLabel.text ? 48 : 40);
self.titleLabel.frame = titleFrame;

CGRect subtitleFrame = self.subtitleLabel.frame;
subtitleFrame.origin.x = titleFrame.origin.x;
subtitleFrame.origin.y = self.bounds.size.height-32;
self.subtitleLabel.frame = subtitleFrame;

CGRect arrowFrame = self.arrow.frame;
arrowFrame.origin.x = ceilf(remainingWidth*position);
self.arrow.frame = arrowFrame;

}

#pragma mark - Scroll View
Expand Down

0 comments on commit b36a9bc

Please sign in to comment.