dkahgld

ZBSetViewController.m 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. //
  2. // ZBSetViewController.m
  3. // ZBProject
  4. //
  5. // Created by 学丽 on 2019/4/4.
  6. // Copyright © 2019 ZB. All rights reserved.
  7. //
  8. #import "ZBSetViewController.h"
  9. #import "ZBSetListCell.h"
  10. @interface ZBSetViewController ()<UITableViewDelegate,UITableViewDataSource>
  11. @property(nonatomic,strong)UITableView *tableViews;
  12. @end
  13. @implementation ZBSetViewController
  14. - (void)viewDidLoad {
  15. [super viewDidLoad];
  16. [self initNavs];
  17. }
  18. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  19. {
  20. return 1;
  21. }
  22. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  23. {
  24. ZBSetListCell *cell =[tableView dequeueReusableCellWithIdentifier:@"cell"];
  25. if (!cell) {
  26. cell =[[ZBSetListCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
  27. cell.accessoryType=UITableViewCellAccessoryNone;
  28. }
  29. cell.selectionStyle=UITableViewCellSelectionStyleNone;
  30. cell.backgroundColor=[UIColor whiteColor];
  31. return cell;
  32. }
  33. -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  34. {
  35. return 1;
  36. }
  37. -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
  38. {
  39. return 10;
  40. }
  41. -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
  42. {
  43. return 50;
  44. }
  45. -(void)initNavs
  46. {
  47. // [self.navBar setShowNavigationBarBottomLine:YES];
  48. [UIApplication sharedApplication].statusBarStyle=UIStatusBarStyleDefault;
  49. self.navBar.backgroundColor=[UIColor whiteColor];
  50. self.view.backgroundColor=[UIColor lineColor];
  51. self.navBar.navTitleLabel.text=@"设置";
  52. self.navBar.navTitleLabel.textColor=[UIColor YHColorWithHex:0x333333];
  53. UIButton *returnBtn =[[UIButton alloc]initWithFrame:CGRectMake(0, 0, 30, 20)];
  54. [returnBtn addTarget:self action:@selector(returnClickBtn) forControlEvents:UIControlEventTouchUpInside];
  55. [returnBtn setImage:[UIImage imageNamed:@"back"] forState:UIControlStateNormal];
  56. returnBtn.adjustsImageWhenHighlighted = NO;
  57. [self.navBar setCustomLeftButtons:@[returnBtn]];
  58. [self.view addSubview:self.tableViews];
  59. [self.tableViews mas_makeConstraints:^(MASConstraintMaker *make) {
  60. make.left.right.mas_equalTo(0);
  61. make.top.mas_equalTo(NavBarHeight);
  62. make.height.mas_equalTo(SCREEN_HEIGHT);
  63. }];
  64. UIButton *exitBtn =[[UIButton alloc]initWithFrame:CGRectMake(0, SCREEN_HEIGHT-50-SafeBottomHeight, SCREEN_WIDTH, 50)];
  65. [exitBtn setTitle:@"退出登录" forState:UIControlStateNormal];
  66. exitBtn.backgroundColor=[UIColor whiteColor];
  67. [exitBtn addTarget:self action:@selector(exitClickBtn) forControlEvents:UIControlEventTouchUpInside];
  68. [exitBtn setTitleColor:[UIColor YHColorWithHex:0xFF7D00] forState:UIControlStateNormal];
  69. [self.view addSubview:exitBtn];
  70. }
  71. #pragma mark---退出登录
  72. -(void)exitClickBtn
  73. {
  74. [[NSNotificationCenter defaultCenter]postNotificationName:@"logout" object:nil userInfo:nil];
  75. [self.navigationController popViewControllerAnimated:YES];
  76. [AccountTool deleteAccount];
  77. UINavigationController *login = [[UINavigationController alloc]initWithRootViewController:[[ZBLoginViewController alloc] init]];
  78. [[UIApplication sharedApplication].keyWindow.rootViewController presentViewController:login animated:YES completion:nil];
  79. }
  80. -(void)returnClickBtn
  81. {
  82. [self.navigationController popViewControllerAnimated:YES];
  83. }
  84. -(UITableView *)tableViews
  85. {
  86. if (!_tableViews) {
  87. _tableViews =[[UITableView alloc]init];
  88. _tableViews.delegate =self;
  89. _tableViews.dataSource=self;
  90. _tableViews.separatorStyle=UITableViewCellSeparatorStyleNone;
  91. _tableViews.backgroundColor=[UIColor YHColorWithHex:0xF2F2F2];
  92. _tableViews.sectionHeaderHeight=10;
  93. }
  94. return _tableViews;
  95. }
  96. @end