口袋优选

KBMyFansViewController.m 8.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. //
  2. // KBMyFansViewController.m
  3. // YouHuiProject
  4. //
  5. // Created by 小花 on 2018/5/19.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "KBMyFansViewController.h"
  9. #import "KBOrderTableView.h"
  10. #import "MLMSegmentHead.h"
  11. #import "MLMSegmentManager.h"
  12. #import "KBChildFansViewController.h"
  13. #import "KBFansHeaderView.h"
  14. #import "KBShowFansHelpView.h"
  15. #import "CCAlertShowView.h"
  16. #import "KBPotentialFansViewController.h"
  17. @interface KBMyFansViewController ()
  18. <
  19. UITableViewDelegate,
  20. UITableViewDataSource,
  21. MLMSegmentScrollDelegate
  22. >
  23. @property (nonatomic, strong) KBOrderTableView *tableView;
  24. @property (nonatomic, strong) KBFansHeaderView *headerView;
  25. @property (nonatomic, strong) MLMSegmentHead *titleView;
  26. @property (nonatomic, strong) MLMSegmentScroll *segScroll;
  27. @property (nonatomic, strong) NSMutableArray *vcList;
  28. @property (nonatomic, assign) BOOL canScroll;
  29. @property (nonatomic, strong) UIButton *rightHelpBtn;
  30. @end
  31. @implementation KBMyFansViewController
  32. - (void)viewDidLoad {
  33. [super viewDidLoad];
  34. [self configNavigationBar];
  35. [self configTableView];
  36. [self creatHeaderViewAndFooterView];
  37. }
  38. - (void)configTableView {
  39. // [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeScrollStatus) name:@"leaveTop" object:nil];
  40. // self.canScroll = YES;
  41. // self.headerView = [[KBFansHeaderView alloc] initWithFrame:CGRectMake(0, 0,SCREEN_WIDTH , 135)];
  42. // self.tableView.tableHeaderView = self.headerView;
  43. [self.view addSubview:self.tableView];
  44. }
  45. - (void)configNavigationBar {
  46. [self.navigationBar setNavTitle:@"我的好友"];
  47. self.navigationBar.backgroundColor = [UIColor changeColor];
  48. self.navigationBar.navTitleLabel.textColor = [UIColor whiteColor];
  49. UIButton *leftBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 40, 40)];
  50. [leftBtn setImage:[UIImage imageNamed:@"back_white"] forState:UIControlStateNormal];
  51. [leftBtn addTarget:self action:@selector(backAction) forControlEvents:UIControlEventTouchUpInside];
  52. [self.navigationBar setCustomLeftButtons:@[leftBtn]];
  53. self.rightHelpBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 40, 40)];
  54. [self.rightHelpBtn setImage:[UIImage imageNamed:@"helpmonth"] forState:UIControlStateNormal];
  55. [self.rightHelpBtn addTarget:self action:@selector(showHelpAlert) forControlEvents:UIControlEventTouchUpInside];
  56. self.rightHelpBtn.hidden = YES;
  57. [self.navigationBar setCustomRightButtons:@[self.rightHelpBtn]];
  58. }
  59. -(void)viewWillAppear:(BOOL)animated{
  60. [super viewWillAppear:animated];
  61. [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
  62. }
  63. - (void)backAction {
  64. [self.navigationController popViewControllerAnimated:YES];
  65. }
  66. - (void)creatHeaderViewAndFooterView {
  67. self.view.backgroundColor = [UIColor whiteColor];
  68. NSArray *titleArr = @[@"全部好友",@"直属好友",@"推荐好友",@"潜在好友"];
  69. for (int i = 0; i < titleArr.count; i++) {
  70. if (i == 3) {
  71. KBPotentialFansViewController *child = [[KBPotentialFansViewController alloc] init];
  72. [self.vcList addObject:child];
  73. }else {
  74. KBChildFansViewController *child = [[KBChildFansViewController alloc] init];
  75. child.type=i;
  76. [self.vcList addObject:child];
  77. }
  78. }
  79. self.segScroll = [[MLMSegmentScroll alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, ChildTableViewHeight) vcOrViews:self.vcList];
  80. self.segScroll.bounces = NO;
  81. __weak typeof(self) weskSelf = self;
  82. self.segScroll.showingIndex = ^(NSInteger index) {
  83. weskSelf.rightHelpBtn.hidden = index!=3;
  84. };
  85. self.titleView = [[MLMSegmentHead alloc] initWithFrame:CGRectMake(0, NavBarHeight, SCREEN_WIDTH, 40) titles:titleArr headStyle:SegmentHeadStyleDefault layoutStyle:MLMSegmentLayoutDefault];
  86. self.titleView.headColor = [UIColor whiteColor];
  87. self.titleView.bottomLineHeight = 1;
  88. self.titleView.bottomLineColor = [UIColor yhGrayColor];
  89. self.titleView.fontScale = 1;
  90. self.titleView.fontSize = 14;
  91. self.titleView.equalSize = YES;
  92. self.titleView.showIndex = 0;
  93. self.titleView.selectColor = [UIColor YHColorWithHex:0xff442a];
  94. self.titleView.deSelectColor = [UIColor YHColorWithHex:0x666666];
  95. [MLMSegmentManager associateHead:self.titleView withScroll:self.segScroll completion:^{
  96. [self.view addSubview:self.titleView];
  97. [self.view addSubview:self.segScroll];
  98. }];
  99. }
  100. #pragma mark ===
  101. - (void)showHelpAlert {
  102. KBShowFansHelpView *popView = [[KBShowFansHelpView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH-80, 213)];
  103. CCAlertShowView *showView = [CCAlertShowView alertViewWithView:popView];
  104. popView.dismissAction = ^{
  105. [showView dismiss];
  106. };
  107. [showView show];
  108. }
  109. #pragma mark --------------------- UITableView delegate -------
  110. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
  111. return 1;
  112. }
  113. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  114. return 1;
  115. }
  116. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  117. return 0.1;
  118. }
  119. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
  120. return 40;
  121. }
  122. - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
  123. return SCREEN_HEIGHT-NavBarHeight-40;
  124. }
  125. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  126. UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"cellID"];
  127. return cell;
  128. }
  129. - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
  130. return self.titleView;
  131. }
  132. - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
  133. return self.segScroll;
  134. }
  135. #pragma mark ----- scroll delegete ----
  136. //- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
  137. // CGFloat bottomCellOffset = [_tableView rectForSection:0].origin.y;
  138. // if (scrollView.contentOffset.y >= bottomCellOffset) {
  139. // scrollView.contentOffset = CGPointMake(0, bottomCellOffset);
  140. // if (self.canScroll) {
  141. // self.canScroll = NO;
  142. // [self setChildViewControllerCanScroll:YES];
  143. // }
  144. // }else{
  145. // if (!self.canScroll) {//子视图没到顶部
  146. // scrollView.contentOffset = CGPointMake(0, bottomCellOffset);
  147. // }
  148. // }
  149. //}
  150. //
  151. //- (void)setChildViewControllerCanScroll:(BOOL)childCanScroll {
  152. // for (KBChildFansViewController *childVc in self.vcList) {
  153. // childVc.childCanScroll = childCanScroll;
  154. // if (!childCanScroll) {
  155. // childVc.tableView.contentOffset = CGPointZero;
  156. // }
  157. // }
  158. //}
  159. #pragma mark ----------------
  160. - (KBOrderTableView *)tableView {
  161. if (!_tableView) {
  162. _tableView = [[KBOrderTableView alloc] initWithFrame:CGRectMake(0, NavBarHeight, SCREEN_WIDTH, SCREEN_HEIGHT-NavBarHeight) style:UITableViewStylePlain];
  163. _tableView.estimatedSectionHeaderHeight = 0;
  164. _tableView.estimatedSectionFooterHeight = 0;
  165. _tableView.sectionFooterHeight = 0;
  166. _tableView.sectionHeaderHeight = 0;
  167. _tableView.estimatedRowHeight = 0;
  168. _tableView.delegate = self;
  169. _tableView.dataSource = self;
  170. _tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
  171. _tableView.backgroundColor = [UIColor yhGrayColor];
  172. _tableView.bounces = NO;
  173. _tableView.showsVerticalScrollIndicator = NO;
  174. [_tableView setSeparatorColor:[UIColor YHColorWithHex:0xdddddd]];
  175. }
  176. return _tableView;
  177. }
  178. - (NSMutableArray *)vcList {
  179. if (!_vcList) {
  180. _vcList = [NSMutableArray array];
  181. }
  182. return _vcList;
  183. }
  184. - (void)didReceiveMemoryWarning {
  185. [super didReceiveMemoryWarning];
  186. // Dispose of any resources that can be recreated.
  187. }
  188. /*
  189. #pragma mark - Navigation
  190. // In a storyboard-based application, you will often want to do a little preparation before navigation
  191. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  192. // Get the new view controller using [segue destinationViewController].
  193. // Pass the selected object to the new view controller.
  194. }
  195. */
  196. @end