MyWalletController.m 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. //
  2. // MyWalletController.m
  3. // model
  4. //
  5. // Created by zuxiukuan on 2018/7/15.
  6. // Copyright © 2018年 Mine. All rights reserved.
  7. // 我的钱包
  8. #import "MyWalletController.h"
  9. #import "WithdrawalController.h"
  10. #import "IncreaseBalanceController.h"
  11. #import "WalletDetailsController.h"
  12. #import "MyWalletCell.h"
  13. @interface MyWalletController ()<UITableViewDelegate, UITableViewDataSource>
  14. @property (nonatomic, strong) UITableView *tableView;
  15. @property (nonatomic, strong) UILabel *moneyLabel;
  16. @property (nonatomic ,strong) NSArray *titlesArr;
  17. @property (nonatomic ,strong) NSArray *imagesArr;
  18. @end
  19. @implementation MyWalletController
  20. - (void)viewWillAppear:(BOOL)animated {
  21. [super viewWillAppear:animated];
  22. self.navigationController.navigationBar.barStyle = UIBarStyleBlack;
  23. //设置导航栏透明
  24. [self.navigationController.navigationBar setTranslucent:true];
  25. //把背景设为空
  26. [self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
  27. //处理导航栏有条线的问题
  28. [self.navigationController.navigationBar setShadowImage:[UIImage new]];
  29. [self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]}];
  30. }
  31. - (void)viewWillDisappear:(BOOL)animated {
  32. [super viewWillDisappear:animated];
  33. self.navigationController.navigationBar.barStyle = UIBarStyleDefault;
  34. //设置导航栏透明
  35. [self.navigationController.navigationBar setTranslucent:NO];
  36. //把背景设为空
  37. [self.navigationController.navigationBar setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault];
  38. //处理导航栏有条线的问题
  39. [self.navigationController.navigationBar setShadowImage:nil];
  40. [self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor blackColor]}];
  41. }
  42. - (void)viewDidLoad {
  43. [super viewDidLoad];
  44. self.view.backgroundColor = [UIColor whiteColor];
  45. self.titlesArr = @[@"提现",@"收入明细",@"提现明细"];
  46. self.imagesArr = @[@"tixian",@"shourumingxi",@"tixianmingxi"];
  47. //设置导航条
  48. [self creatNavBar];
  49. //设置TableView
  50. [self creatTableView];
  51. }
  52. - (void)didReceiveMemoryWarning {
  53. [super didReceiveMemoryWarning];
  54. // Dispose of any resources that can be recreated.
  55. }
  56. - (void)creatNavBar {
  57. self.title = @"我的钱包";
  58. //返回按钮
  59. UIButton * btn = [UIButton buttonWithType:UIButtonTypeCustom];
  60. btn.frame = CGRectMake(0, 0, 40, 40);
  61. [btn setImage:[UIImage imageNamed:@"fanhui1"] forState:UIControlStateNormal];
  62. btn.imageEdgeInsets = UIEdgeInsetsMake(0, -20, 0, 0);
  63. [btn addTarget:self action:@selector(backClick) forControlEvents:UIControlEventTouchUpInside];
  64. UIBarButtonItem *leftItem = [[UIBarButtonItem alloc] initWithCustomView:btn];
  65. UIBarButtonItem *nagetiveSpacer = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
  66. // nagetiveSpacer.width = -12;//这个值可以根据自己需要自己调整
  67. self.navigationItem.leftBarButtonItems = @[nagetiveSpacer, leftItem];
  68. }
  69. - (void)backClick {
  70. [self.navigationController popViewControllerAnimated:YES];
  71. }
  72. - (void)creatTableView {
  73. CGFloat headerHeight = (HeightStatusBar == 44) ? 219 : 175;
  74. UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, headerHeight)];
  75. UIImageView *bgView = [[UIImageView alloc] initWithFrame:headerView.bounds];
  76. [bgView setImage:[UIImage imageNamed:@"jianbianbeijing"]];
  77. [headerView addSubview:bgView];
  78. UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, Height_NaviBar + 30, ScreenWidth / 2, 15)];
  79. titleLabel.text = @"资产总额:";
  80. titleLabel.textAlignment = NSTextAlignmentLeft;
  81. titleLabel.font = [UIFont systemFontOfSize:15];
  82. titleLabel.textColor = RGBValueColor(0xffffff, 1.0);
  83. [headerView addSubview:titleLabel];
  84. self.moneyLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(titleLabel.frame) + 7, ScreenWidth, 30)];
  85. self.moneyLabel.textAlignment = NSTextAlignmentCenter;
  86. self.moneyLabel.textColor = RGBValueColor(0xffffff, 1.0);
  87. NSString *str = [NSString stringWithFormat:@"%@元",self.amount];
  88. NSMutableAttributedString *attrString = [[NSMutableAttributedString alloc] initWithString:str];
  89. [attrString addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:30] range:NSMakeRange(0,str.length - 1)];
  90. [attrString addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:16] range:NSMakeRange(str.length - 1,1)];
  91. self.moneyLabel.attributedText = attrString;
  92. [headerView addSubview:self.moneyLabel];
  93. [self.view addSubview:headerView];
  94. //
  95. self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(headerView.frame), ScreenWidth, ScreenHeight) style:UITableViewStyleGrouped];
  96. self.tableView.backgroundColor = RGBValueColor(0xf7f7f7, 1.0);
  97. self.tableView.delegate = self;
  98. self.tableView.dataSource = self;
  99. self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  100. self.tableView.scrollEnabled = NO;
  101. [self.view addSubview:self.tableView];
  102. [self.tableView registerClass:[MyWalletCell class] forCellReuseIdentifier:@"WalletCell"];
  103. }
  104. #pragma mark -- UITableViewDelegate, UITableViewDataSource
  105. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
  106. return 2;
  107. }
  108. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  109. if (section == 0) {
  110. return 1;
  111. } else {
  112. return 2;
  113. }
  114. }
  115. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  116. MyWalletCell *cell = [tableView dequeueReusableCellWithIdentifier:@"WalletCell" forIndexPath:indexPath];
  117. if (indexPath.section == 0) {
  118. cell.iconImageView.image = [UIImage imageNamed:self.imagesArr[indexPath.row]];
  119. cell.titleLabel.text = self.titlesArr[indexPath.row];
  120. } else {
  121. cell.iconImageView.image = [UIImage imageNamed:self.imagesArr[indexPath.row + 1]];
  122. cell.titleLabel.text = self.titlesArr[indexPath.row + 1];
  123. }
  124. return cell;
  125. }
  126. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  127. return 50;
  128. }
  129. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
  130. return 10;
  131. }
  132. - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
  133. return 0.01;
  134. }
  135. - (nullable UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
  136. UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, 10)];
  137. headerView.backgroundColor = RGBValueColor(0xf7f7f7, 1.0);
  138. return headerView;
  139. }
  140. - (nullable UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
  141. UIView *footerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, 0.01)];
  142. footerView.backgroundColor = RGBValueColor(0xf7f7f7, 1.0);
  143. return footerView;
  144. }
  145. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  146. if (indexPath.section == 0) {
  147. // 提现
  148. WithdrawalController *withdrawalVC = [[WithdrawalController alloc] init];
  149. withdrawalVC.passBackAmount = ^(NSString *string) {
  150. self.amount = string;
  151. NSString *str = [NSString stringWithFormat:@"%@元",self.amount];
  152. NSMutableAttributedString *attrString = [[NSMutableAttributedString alloc] initWithString:str];
  153. [attrString addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:30] range:NSMakeRange(0,str.length - 1)];
  154. [attrString addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:16] range:NSMakeRange(str.length - 1,1)];
  155. self.moneyLabel.attributedText = attrString;
  156. };
  157. [self.navigationController pushViewController:withdrawalVC animated:YES];
  158. } else {
  159. if (indexPath.row == 0) { //收入明细
  160. WalletDetailsController *withdrawalVC = [[WalletDetailsController alloc] init];
  161. withdrawalVC.detailsIndex = @"1";
  162. [self.navigationController pushViewController:withdrawalVC animated:YES];
  163. } else { //提现明细
  164. WalletDetailsController *withdrawalVC = [[WalletDetailsController alloc] init];
  165. withdrawalVC.detailsIndex = @"2";
  166. [self.navigationController pushViewController:withdrawalVC animated:YES];
  167. }
  168. }
  169. }
  170. @end