Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Tree: b99471104a
Fetching contributors…

Cannot retrieve contributors at this time

85 lines (67 sloc) 2.787 kB
//
// SSPullToRefreshDefaultContentView
// SSPullToRefresh
//
// Created by Sam Soffes on 4/9/12.
// Copyright (c) 2012 Sam Soffes. All rights reserved.
//
#import "SSPullToRefreshDefaultContentView.h"
@implementation SSPullToRefreshDefaultContentView
@synthesize statusLabel = _statusLabel;
@synthesize lastUpdatedAtLabel = _lastUpdatedAtLabel;
@synthesize activityIndicatorView = _activityIndicatorView;
#pragma mark - UIView
- (id)initWithFrame:(CGRect)frame {
if ((self = [super initWithFrame:frame])) {
CGFloat width = self.bounds.size.width;
_statusLabel = [[UILabel alloc] initWithFrame:CGRectMake(0.0f, 14.0f, width, 20.0f)];
_statusLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth;
_statusLabel.font = [UIFont boldSystemFontOfSize:14.0f];
_statusLabel.textColor = [UIColor blackColor];
_statusLabel.backgroundColor = [UIColor clearColor];
_statusLabel.textAlignment = UITextAlignmentCenter;
[self addSubview:_statusLabel];
_lastUpdatedAtLabel = [[UILabel alloc] initWithFrame:CGRectMake(0.0f, 34.0f, width, 20.0f)];
_lastUpdatedAtLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth;
_lastUpdatedAtLabel.font = [UIFont systemFontOfSize:12.0f];
_lastUpdatedAtLabel.textColor = [UIColor lightGrayColor];
_lastUpdatedAtLabel.backgroundColor = [UIColor clearColor];
_lastUpdatedAtLabel.textAlignment = UITextAlignmentCenter;
[self addSubview:_lastUpdatedAtLabel];
_activityIndicatorView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
_activityIndicatorView.frame = CGRectMake(30.0f, 25.0f, 20.0f, 20.0f);
[self addSubview:_activityIndicatorView];
}
return self;
}
#pragma mark - SSPullToRefreshContentView
- (void)setState:(SSPullToRefreshViewState)state withPullToRefreshView:(SSPullToRefreshView *)view {
switch (state) {
case SSPullToRefreshViewStateReady: {
_statusLabel.text = @"Release to refresh...";
[_activityIndicatorView stopAnimating];
break;
}
case SSPullToRefreshViewStateNormal: {
_statusLabel.text = @"Pull down to refresh...";
[_activityIndicatorView stopAnimating];
break;
}
case SSPullToRefreshViewStateLoading:
case SSPullToRefreshViewStateClosing: {
_statusLabel.text = @"Loading...";
[_activityIndicatorView startAnimating];
break;
}
}
}
- (void)setLastUpdatedAt:(NSDate *)date withPullToRefreshView:(SSPullToRefreshView *)view {
static NSDateFormatter *dateFormatter = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
dateFormatter = [[NSDateFormatter alloc] init];
dateFormatter.dateStyle = NSDateFormatterLongStyle;
});
_lastUpdatedAtLabel.text = [NSString stringWithFormat:@"Last Updated: %@", [dateFormatter stringFromDate:date]];
}
@end
Jump to Line
Something went wrong with that request. Please try again.