Permalink
Browse files

Honor the content view's `sizeThatFits:`

  • Loading branch information...
1 parent d6c597e commit 6a9455cc0743e5959188734cbf3146747ffe1e50 @soffes soffes committed May 18, 2012
Showing with 13 additions and 1 deletion.
  1. +1 −0 SSPullToRefreshView.h
  2. +12 −1 SSPullToRefreshView.m
View
@@ -111,6 +111,7 @@ typedef enum {
@optional
+- (CGSize)contentSize;
- (void)setPullProgress:(CGFloat)pullProgress;
- (void)setLastUpdatedAt:(NSDate *)date withPullToRefreshView:(SSPullToRefreshView *)view;
View
@@ -47,6 +47,7 @@ - (void)setState:(SSPullToRefreshViewState)state {
[_delegate pullToRefreshViewShouldRefreshDidFinishLoading:self];
}
} else if (!loading && _state == SSPullToRefreshViewStateLoading) {
+ [self _setPullProgress:1.0f];
if ([_delegate respondsToSelector:@selector(pullToRefreshViewShouldRefreshDidStartLoading:)]) {
[_delegate pullToRefreshViewShouldRefreshDidStartLoading:self];
}
@@ -119,7 +120,17 @@ - (void)removeFromSuperview {
- (void)layoutSubviews {
CGSize size = self.bounds.size;
- _contentView.frame = CGRectMake(0.0f, size.height - _expandedHeight, size.width, _expandedHeight);
+ CGSize contentSize = [self.contentView sizeThatFits:size];
+
+ if (contentSize.width < size.width) {
+ contentSize.width = size.width;
+ }
+
+ if (contentSize.height < _expandedHeight) {
+ contentSize.height = _expandedHeight;
+ }
+
+ self.contentView.frame = CGRectMake(roundf((size.width - contentSize.width) / 2.0f), size.height - contentSize.height, contentSize.width, contentSize.height);
}

0 comments on commit 6a9455c

Please sign in to comment.