PageLoadFootView.m 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. //
  2. // PageLoadFootView.m
  3. // wq
  4. //
  5. // Created by weqia on 13-7-22.
  6. // Copyright (c) 2013年 Weqia. All rights reserved.
  7. //
  8. #import "PageLoadFootView.h"
  9. @implementation PageLoadFootView
  10. @synthesize delegate;
  11. - (id)initWithFrame:(CGRect)frame
  12. {
  13. self = [super initWithFrame:frame];
  14. if (self) {
  15. // Initialization code
  16. isLoading=NO;
  17. self.frame=CGRectMake(0, 0, JX_SCREEN_WIDTH, 40);
  18. image=[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"dialog_load"]];
  19. image.frame=CGRectMake(120, 23, 15, 15);
  20. [self addSubview:image];
  21. UILabel * label=[[UILabel alloc]initWithFrame:CGRectMake(140, 20, 60, 20)];
  22. label.backgroundColor=[UIColor clearColor];
  23. label.textAlignment=NSTextAlignmentCenter;
  24. label.textColor=[UIColor grayColor];
  25. label.text=Localized(@"PageLoadFootView_Loading");
  26. label.font=[UIFont systemFontOfSize:12];
  27. loadText=label;
  28. [self addSubview:label];
  29. label=[[UILabel alloc]initWithFrame:CGRectMake(130, 20, 60, 20)];
  30. label.backgroundColor=[UIColor clearColor];
  31. label.textAlignment=NSTextAlignmentCenter;
  32. label.textColor=[UIColor grayColor];
  33. label.text=Localized(@"PageLoadFootView_LoadOK");
  34. label.font=[UIFont systemFontOfSize:12];
  35. finishText=label;
  36. [label setHidden:YES];
  37. // [self addSubview:label];
  38. CABasicAnimation* rotationAnimation;
  39. rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
  40. rotationAnimation.toValue = [NSNumber numberWithFloat: M_PI * 2.0 ];
  41. rotationAnimation.duration = 1;
  42. rotationAnimation.cumulative = YES;
  43. rotationAnimation.repeatCount = MAXFLOAT;
  44. [image.layer addAnimation:rotationAnimation forKey:@"rotationAnimation"];
  45. }
  46. return self;
  47. }
  48. -(void) animmation
  49. {
  50. CABasicAnimation* rotationAnimation;
  51. rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
  52. rotationAnimation.toValue = [NSNumber numberWithFloat: M_PI * 2.0 ];
  53. rotationAnimation.duration = 1;
  54. rotationAnimation.cumulative = YES;
  55. rotationAnimation.repeatCount = MAXFLOAT;
  56. [image.layer addAnimation:rotationAnimation forKey:@"rotationAnimation"];
  57. }
  58. -(void) scrollViewDidEndDecelerating:(UIScrollView *)scrollView
  59. {
  60. float h=scrollView.contentSize.height-scrollView.frame.size.height-20;
  61. if(scrollView.contentOffset.y>=h&&!isLoading&&scrollView.contentOffset.y>50)
  62. {
  63. [self begin];
  64. isLoading=YES;
  65. if(delegate&&[delegate respondsToSelector:@selector(footViewBeginLoad:)])
  66. [delegate footViewBeginLoad:self];
  67. }
  68. }
  69. -(void) loadFinish
  70. {
  71. isLoading=NO;
  72. [self end];
  73. }
  74. -(void)begin
  75. {
  76. [image setHidden:NO];
  77. [loadText setHidden:NO];
  78. [finishText setHidden:YES];
  79. }
  80. -(void)end
  81. {
  82. [image setHidden:YES];
  83. [loadText setHidden:YES];
  84. [finishText setHidden:NO];
  85. }
  86. /*
  87. // Only override drawRect: if you perform custom drawing.
  88. // An empty implementation adversely affects performance during animation.
  89. - (void)drawRect:(CGRect)rect
  90. {
  91. // Drawing code
  92. }
  93. */
  94. @end