| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192 |
- //
- // MyWalletController.m
- // model
- //
- // Created by zuxiukuan on 2018/7/15.
- // Copyright © 2018年 Mine. All rights reserved.
- // 我的钱包
- #import "MyWalletController.h"
- #import "WithdrawalController.h"
- #import "IncreaseBalanceController.h"
- #import "WalletDetailsController.h"
- #import "MyWalletCell.h"
- #import "WithdrawController.h"
- @interface MyWalletController ()<UITableViewDelegate, UITableViewDataSource>
- @property (nonatomic, strong) UITableView *tableView;
- @property (nonatomic, strong) UILabel *moneyLabel;
- @property (nonatomic ,strong) NSArray *titlesArr;
- @property (nonatomic ,strong) NSArray *imagesArr;
- @end
- @implementation MyWalletController
- - (void)viewWillAppear:(BOOL)animated {
- [super viewWillAppear:animated];
- self.navigationController.navigationBar.barStyle = UIBarStyleBlack;
- [self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
- [self.navigationController.navigationBar setShadowImage:[UIImage new]];
- [self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]}];
- }
- - (void)viewWillDisappear:(BOOL)animated {
- [super viewWillDisappear:animated];
- self.navigationController.navigationBar.barStyle = UIBarStyleDefault;
- [self.navigationController.navigationBar setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault];
- [self.navigationController.navigationBar setShadowImage:nil];
- [self.navigationController.navigationBar setTitleTextAttributes:nil];
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
-
- self.view.backgroundColor = [UIColor whiteColor];
- self.titlesArr = @[@"提现",@"收入明细",@"提现明细"];
- self.imagesArr = @[@"tixian",@"shourumingxi",@"tixianmingxi"];
- //设置导航条
- [self creatNavBar];
- //设置TableView
- [self creatTableView];
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- - (void)creatNavBar {
- self.title = @"我的钱包";
- //返回按钮
- UIButton * btn = [UIButton buttonWithType:UIButtonTypeCustom];
- btn.frame = CGRectMake(0, 0, 40, 40);
- [btn setImage:[UIImage imageNamed:@"fanhui1"] forState:UIControlStateNormal];
- btn.imageEdgeInsets = UIEdgeInsetsMake(0, -20, 0, 0);
- [btn addTarget:self action:@selector(backClick) forControlEvents:UIControlEventTouchUpInside];
- UIBarButtonItem *leftItem = [[UIBarButtonItem alloc] initWithCustomView:btn];
- UIBarButtonItem *nagetiveSpacer = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
- // nagetiveSpacer.width = -12;//这个值可以根据自己需要自己调整
- self.navigationItem.leftBarButtonItems = @[nagetiveSpacer, leftItem];
- }
- - (void)backClick {
- [self.navigationController popViewControllerAnimated:YES];
- }
- - (void)creatTableView {
- CGFloat headerHeight = (HeightStatusBar == 44) ? 219 : 175;
- UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, headerHeight)];
- UIImageView *bgView = [[UIImageView alloc] initWithFrame:headerView.bounds];
- [bgView setImage:[UIImage imageNamed:@"jianbianbeijing"]];
- [headerView addSubview:bgView];
-
- UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, Height_NaviBar + 30, ScreenWidth / 2, 15)];
- titleLabel.text = @"资产总额:";
- titleLabel.textAlignment = NSTextAlignmentLeft;
- titleLabel.font = [UIFont systemFontOfSize:15];
- titleLabel.textColor = RGBValueColor(0xffffff, 1.0);
- [headerView addSubview:titleLabel];
-
- self.moneyLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(titleLabel.frame) + 7, ScreenWidth, 30)];
- self.moneyLabel.textAlignment = NSTextAlignmentCenter;
- self.moneyLabel.textColor = RGBValueColor(0xffffff, 1.0);
- NSString *str = [NSString stringWithFormat:@"%@元",self.amount];
- NSMutableAttributedString *attrString = [[NSMutableAttributedString alloc] initWithString:str];
- [attrString addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:30] range:NSMakeRange(0,str.length - 1)];
- [attrString addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:16] range:NSMakeRange(str.length - 1,1)];
- self.moneyLabel.attributedText = attrString;
- [headerView addSubview:self.moneyLabel];
- [self.view addSubview:headerView];
-
- //
- self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(headerView.frame), ScreenWidth, ScreenHeight) style:UITableViewStyleGrouped];
- self.tableView.backgroundColor = RGBValueColor(0xf7f7f7, 1.0);
- self.tableView.delegate = self;
- self.tableView.dataSource = self;
- self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
- self.tableView.scrollEnabled = NO;
- [self.view addSubview:self.tableView];
- [self.tableView registerClass:[MyWalletCell class] forCellReuseIdentifier:@"WalletCell"];
- }
- #pragma mark -- UITableViewDelegate, UITableViewDataSource
- - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
- return 2;
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
- if (section == 0) {
- return 1;
- } else {
- return 2;
- }
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
-
- MyWalletCell *cell = [tableView dequeueReusableCellWithIdentifier:@"WalletCell" forIndexPath:indexPath];
-
- if (indexPath.section == 0) {
- cell.iconImageView.image = [UIImage imageNamed:self.imagesArr[indexPath.row]];
- cell.titleLabel.text = self.titlesArr[indexPath.row];
- } else {
- cell.iconImageView.image = [UIImage imageNamed:self.imagesArr[indexPath.row + 1]];
- cell.titleLabel.text = self.titlesArr[indexPath.row + 1];
- }
- return cell;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
- return 50;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
- return 10;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
- return 0.01;
- }
- - (nullable UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
- UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, 10)];
- headerView.backgroundColor = RGBValueColor(0xf7f7f7, 1.0);
- return headerView;
- }
- - (nullable UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
- UIView *footerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, 0.01)];
- footerView.backgroundColor = RGBValueColor(0xf7f7f7, 1.0);
- return footerView;
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
-
- if (indexPath.section == 0) {
- // 提现
- WithdrawController *withdrawalVC = [[WithdrawController alloc] init];
- withdrawalVC.callback = ^(NSString *string) {
- self.amount = string;
- NSString *str = [NSString stringWithFormat:@"%@元",self.amount];
- NSMutableAttributedString *attrString = [[NSMutableAttributedString alloc] initWithString:str];
- [attrString addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:30] range:NSMakeRange(0,str.length - 1)];
- [attrString addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:16] range:NSMakeRange(str.length - 1,1)];
- self.moneyLabel.attributedText = attrString;
- };
- [self.navigationController pushViewController:withdrawalVC animated:YES];
- } else {
- if (indexPath.row == 0) { //收入明细
- WalletDetailsController *withdrawalVC = [[WalletDetailsController alloc] init];
- withdrawalVC.detailsIndex = @"1";
- [self.navigationController pushViewController:withdrawalVC animated:YES];
- } else { //提现明细
- WalletDetailsController *withdrawalVC = [[WalletDetailsController alloc] init];
- withdrawalVC.detailsIndex = @"2";
- [self.navigationController pushViewController:withdrawalVC animated:YES];
- }
- }
- }
- @end
|