MyWalletController.m 8.1 KB

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