Permalink
Browse files

Updated for 4.0 and retina display.

  • Loading branch information...
1 parent 9b825d3 commit a35b029c6db956733ba9d0b39e0375f4495ec609 @devindoty devindoty committed Sep 17, 2010
View
BIN .DS_Store
Binary file not shown.
View
Binary file not shown.
Binary file not shown.
@@ -36,10 +36,10 @@ typedef enum{
@interface EGORefreshTableHeaderView : UIView {
- UILabel *lastUpdatedLabel;
- UILabel *statusLabel;
- CALayer *arrowImage;
- UIActivityIndicatorView *activityView;
+ UILabel *_lastUpdatedLabel;
+ UILabel *_statusLabel;
+ CALayer *_arrowImage;
+ UIActivityIndicatorView *_activityView;
EGOPullRefreshState _state;
@@ -29,7 +29,7 @@
#define TEXT_COLOR [UIColor colorWithRed:87.0/255.0 green:108.0/255.0 blue:137.0/255.0 alpha:1.0]
#define BORDER_COLOR [UIColor colorWithRed:87.0/255.0 green:108.0/255.0 blue:137.0/255.0 alpha:1.0]
-
+#define FLIP_ANIMATION_DURATION 0.18f
@implementation EGORefreshTableHeaderView
@@ -40,70 +40,71 @@ - (id)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
self.autoresizingMask = UIViewAutoresizingFlexibleWidth;
-
- lastUpdatedLabel = [[UILabel alloc] initWithFrame:CGRectMake(0.0f, frame.size.height - 30.0f, self.frame.size.width, 20.0f)];
- lastUpdatedLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth;
- lastUpdatedLabel.font = [UIFont systemFontOfSize:12.0f];
- lastUpdatedLabel.textColor = TEXT_COLOR;
- lastUpdatedLabel.shadowColor = [UIColor colorWithWhite:0.9f alpha:1.0f];
- lastUpdatedLabel.shadowOffset = CGSizeMake(0.0f, 1.0f);
- lastUpdatedLabel.backgroundColor = [UIColor clearColor];
- lastUpdatedLabel.textAlignment = UITextAlignmentCenter;
- [self addSubview:lastUpdatedLabel];
- [lastUpdatedLabel release];
+
+ UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0.0f, frame.size.height - 30.0f, self.frame.size.width, 20.0f)];
+ label.autoresizingMask = UIViewAutoresizingFlexibleWidth;
+ label.font = [UIFont systemFontOfSize:12.0f];
+ label.textColor = TEXT_COLOR;
+ label.shadowColor = [UIColor colorWithWhite:0.9f alpha:1.0f];
+ label.shadowOffset = CGSizeMake(0.0f, 1.0f);
+ label.backgroundColor = [UIColor clearColor];
+ label.textAlignment = UITextAlignmentCenter;
+ [self addSubview:label];
+ _lastUpdatedLabel=label;
+ [label release];
if ([[NSUserDefaults standardUserDefaults] objectForKey:@"EGORefreshTableView_LastRefresh"]) {
- lastUpdatedLabel.text = [[NSUserDefaults standardUserDefaults] objectForKey:@"EGORefreshTableView_LastRefresh"];
+ _lastUpdatedLabel.text = [[NSUserDefaults standardUserDefaults] objectForKey:@"EGORefreshTableView_LastRefresh"];
} else {
[self setCurrentDate];
}
- statusLabel = [[UILabel alloc] initWithFrame:CGRectMake(0.0f, frame.size.height - 48.0f, self.frame.size.width, 20.0f)];
- statusLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth;
- statusLabel.font = [UIFont boldSystemFontOfSize:13.0f];
- statusLabel.textColor = TEXT_COLOR;
- statusLabel.shadowColor = [UIColor colorWithWhite:0.9f alpha:1.0f];
- statusLabel.shadowOffset = CGSizeMake(0.0f, 1.0f);
- statusLabel.backgroundColor = [UIColor clearColor];
- statusLabel.textAlignment = UITextAlignmentCenter;
- [self setState:EGOOPullRefreshNormal];
- [self addSubview:statusLabel];
- [statusLabel release];
+ label = [[UILabel alloc] initWithFrame:CGRectMake(0.0f, frame.size.height - 48.0f, self.frame.size.width, 20.0f)];
+ label.autoresizingMask = UIViewAutoresizingFlexibleWidth;
+ label.font = [UIFont boldSystemFontOfSize:13.0f];
+ label.textColor = TEXT_COLOR;
+ label.shadowColor = [UIColor colorWithWhite:0.9f alpha:1.0f];
+ label.shadowOffset = CGSizeMake(0.0f, 1.0f);
+ label.backgroundColor = [UIColor clearColor];
+ label.textAlignment = UITextAlignmentCenter;
+ [self addSubview:label];
+ _statusLabel=label;
+ [label release];
+
+ CALayer *layer = [[CALayer alloc] init];
+ layer.frame = CGRectMake(25.0f, frame.size.height - 65.0f, 30.0f, 55.0f);
+ layer.contentsGravity = kCAGravityResizeAspect;
+ layer.contents = (id)[UIImage imageNamed:@"blueArrow.png"].CGImage;
+
+#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 40000
+ if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]) {
+ layer.contentsScale = [[UIScreen mainScreen] scale];
+ }
+#endif
+
+ [[self layer] addSublayer:layer];
+ _arrowImage=layer;
+ [layer release];
- arrowImage = [[CALayer alloc] init];
- arrowImage.frame = CGRectMake(25.0f, frame.size.height - 65.0f, 30.0f, 55.0f);
- arrowImage.contentsGravity = kCAGravityResizeAspect;
- arrowImage.contents = (id)[UIImage imageNamed:@"blueArrow.png"].CGImage;
- [[self layer] addSublayer:arrowImage];
- [arrowImage release];
+ UIActivityIndicatorView *view = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
+ view.frame = CGRectMake(25.0f, frame.size.height - 38.0f, 20.0f, 20.0f);
+ [self addSubview:view];
+ _activityView = view;
+ [view release];
- activityView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
- activityView.frame = CGRectMake(25.0f, frame.size.height - 38.0f, 20.0f, 20.0f);
- activityView.hidesWhenStopped = YES;
- [self addSubview:activityView];
- [activityView release];
+ [self setState:EGOOPullRefreshNormal];
}
return self;
}
-- (void)drawRect:(CGRect)rect{
- CGContextRef context = UIGraphicsGetCurrentContext();
- CGContextDrawPath(context, kCGPathFillStroke);
- [BORDER_COLOR setStroke];
- CGContextBeginPath(context);
- CGContextMoveToPoint(context, 0.0f, self.bounds.size.height - 1);
- CGContextAddLineToPoint(context, self.bounds.size.width, self.bounds.size.height - 1);
- CGContextStrokePath(context);
-}
-
- (void)setCurrentDate {
- NSDateFormatter* formatter = [[NSDateFormatter alloc] init];
+ NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setAMSymbol:@"AM"];
[formatter setPMSymbol:@"PM"];
[formatter setDateFormat:@"MM/dd/yyyy hh:mm:a"];
- lastUpdatedLabel.text = [NSString stringWithFormat:@"Last Updated: %@", [formatter stringFromDate:[NSDate date]]];
- [[NSUserDefaults standardUserDefaults] setObject:lastUpdatedLabel.text forKey:@"EGORefreshTableView_LastRefresh"];
+ _lastUpdatedLabel.text = [NSString stringWithFormat:@"Last Updated: %@", [formatter stringFromDate:[NSDate date]]];
+ [[NSUserDefaults standardUserDefaults] setObject:_lastUpdatedLabel.text forKey:@"EGORefreshTableView_LastRefresh"];
[[NSUserDefaults standardUserDefaults] synchronize];
[formatter release];
}
@@ -113,38 +114,38 @@ - (void)setState:(EGOPullRefreshState)aState{
switch (aState) {
case EGOOPullRefreshPulling:
- statusLabel.text = @"Release to refresh...";
+ _statusLabel.text = NSLocalizedString(@"Release to refresh...", @"Release to refresh status");
[CATransaction begin];
- [CATransaction setAnimationDuration:.18];
- arrowImage.transform = CATransform3DMakeRotation((M_PI / 180.0) * 180.0f, 0.0f, 0.0f, 1.0f);
+ [CATransaction setAnimationDuration:FLIP_ANIMATION_DURATION];
+ _arrowImage.transform = CATransform3DMakeRotation((M_PI / 180.0) * 180.0f, 0.0f, 0.0f, 1.0f);
[CATransaction commit];
break;
case EGOOPullRefreshNormal:
if (_state == EGOOPullRefreshPulling) {
[CATransaction begin];
- [CATransaction setAnimationDuration:.18];
- arrowImage.transform = CATransform3DIdentity;
+ [CATransaction setAnimationDuration:FLIP_ANIMATION_DURATION];
+ _arrowImage.transform = CATransform3DIdentity;
[CATransaction commit];
}
- statusLabel.text = @"Pull down to refresh...";
- [activityView stopAnimating];
+ _statusLabel.text = NSLocalizedString(@"Pull down to refresh...", @"Pull down to refresh status");
+ [_activityView stopAnimating];
[CATransaction begin];
[CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions];
- arrowImage.hidden = NO;
- arrowImage.transform = CATransform3DIdentity;
+ _arrowImage.hidden = NO;
+ _arrowImage.transform = CATransform3DIdentity;
[CATransaction commit];
break;
case EGOOPullRefreshLoading:
- statusLabel.text = @"Loading...";
- [activityView startAnimating];
+ _statusLabel.text = NSLocalizedString(@"Loading...", @"Loading Status");
+ [_activityView startAnimating];
[CATransaction begin];
[CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions];
- arrowImage.hidden = YES;
+ _arrowImage.hidden = YES;
[CATransaction commit];
break;
@@ -156,10 +157,10 @@ - (void)setState:(EGOPullRefreshState)aState{
}
- (void)dealloc {
- activityView = nil;
- statusLabel = nil;
- arrowImage = nil;
- lastUpdatedLabel = nil;
+ _activityView = nil;
+ _statusLabel = nil;
+ _arrowImage = nil;
+ _lastUpdatedLabel = nil;
[super dealloc];
}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.

0 comments on commit a35b029

Please sign in to comment.