LoadMoreView.m 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. //
  2. // LoadMoreView.m
  3. // Manzi
  4. //
  5. // Created by wei on 12-9-22.
  6. // Copyright (c) 2012年 wei. All rights reserved.
  7. //
  8. #import "LoadMoreView.h"
  9. @implementation LoadMoreView
  10. @synthesize delegate, OnLoadMore;
  11. - (void)OnLoadMoreClick {
  12. if (delegate && OnLoadMore) {
  13. [delegate performSelector:OnLoadMore withObject:self];
  14. }
  15. }
  16. - (id)initWithFrame:(CGRect)frame
  17. {
  18. self = [super initWithFrame:frame];
  19. if (self) {
  20. self.backgroundColor = [UIColor clearColor];
  21. mLoadMore = [UIButton buttonWithType:UIButtonTypeCustom];
  22. mLoadMore.frame = self.bounds;
  23. mLoadMore.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
  24. [mLoadMore addTarget:self action:@selector(OnLoadMoreClick) forControlEvents:UIControlEventTouchUpInside];
  25. [mLoadMore setBackgroundImage:[UIImage imageNamed:@"btnmore.png"] forState:UIControlStateNormal];
  26. mLoadMore.adjustsImageWhenHighlighted = YES;
  27. mLoadMore.adjustsImageWhenDisabled = YES;
  28. [self addSubview:mLoadMore];
  29. _mlbText = [[UILabel alloc] initWithFrame:mLoadMore.bounds];
  30. _mlbText.autoresizingMask = UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth;
  31. _mlbText.backgroundColor = [UIColor clearColor];
  32. _mlbText.textAlignment = NSTextAlignmentCenter;
  33. _mlbText.font = [UIFont systemFontOfSize:14];
  34. _mlbText.textColor = [UIColor darkGrayColor];
  35. _mlbText.shadowOffset = CGSizeMake(1, 1);
  36. _mlbText.shadowColor = [UIColor whiteColor];
  37. _mlbText.text = @"显示下一页";
  38. [mLoadMore addSubview:_mlbText];
  39. // [mlbText release];
  40. }
  41. return self;
  42. }
  43. - (void)StartLoading {
  44. mLoadMore.enabled = NO;
  45. _mlbText.text = @"加载数据中⋯";
  46. }
  47. - (void)StopLoading {
  48. mLoadMore.enabled = YES;
  49. _mlbText.text = @"显示下一页";
  50. }
  51. /*
  52. // Only override drawRect: if you perform custom drawing.
  53. // An empty implementation adversely affects performance during animation.
  54. - (void)drawRect:(CGRect)rect
  55. {
  56. // Drawing code
  57. }
  58. */
  59. @end