MySetViewController.m 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. //
  2. // MySetViewController.m
  3. // 双子星云手机
  4. //
  5. // Created by APPLE on 2023/8/17.
  6. //
  7. #import "MySetViewController.h"
  8. #import <SDWebImage.h>
  9. #import <Masonry.h>
  10. #import "UseAccountManage.h"
  11. #import "HelpDownScrollView.h"
  12. #import "MineViewCell.h"
  13. #import "ChangeLogoViewController.h"
  14. @interface MySetViewController ()<HelpDownScrollViewDelegate,UITableViewDelegate,UITableViewDataSource>
  15. @property (nonatomic, strong, nullable) UITableView *tableView;
  16. @end
  17. @implementation MySetViewController
  18. - (void)viewDidLoad {
  19. [super viewDidLoad];
  20. // Do any additional setup after loading the view.
  21. [self drawAnyView];
  22. }
  23. - (void)drawAnyView{
  24. [self.view setBackgroundColor:HWF5F7FAColor];
  25. [self.toolBar setHidden:YES];
  26. [self.navigationBar setHidden:YES];
  27. [self.view addSubview:self.tableView];
  28. [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
  29. make.left.mas_equalTo(0);
  30. make.right.mas_equalTo(0);
  31. make.bottom.mas_equalTo(0);
  32. make.top.mas_equalTo(0);
  33. }];
  34. [self.tableView setTableHeaderView:[self headViewForTable]];
  35. }
  36. - (UIView *)headViewForTable{
  37. /*236顶部视图, 44中间试图下部分, 126下方视图*/
  38. UIView *headView = [[UIView alloc] initWithFrame:(CGRectMake(0, 0, SCREEN_W, 236.f + 44.f + 126))];
  39. [headView setBackgroundColor:[UIColor clearColor]];
  40. UIImage *bgImage = [UIImage imageNamed:@"set_up_bg"];
  41. // bgImage = [bgImage resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 40, 80)];
  42. UIImageView *bgImView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, 236.f)];
  43. [bgImView setImage:bgImage];
  44. [headView addSubview:bgImView];
  45. /*头像*/
  46. UIImageView *photoImage = [[UIImageView alloc] init];
  47. [photoImage setImage:[UIImage imageNamed:@"photo_normal"]];
  48. [bgImView addSubview:photoImage];
  49. [photoImage mas_makeConstraints:^(MASConstraintMaker *make) {
  50. make.left.mas_equalTo(16.f);
  51. make.top.mas_equalTo(99.f);
  52. make.width.mas_equalTo(62.f);
  53. make.height.mas_equalTo(62.f);
  54. }];
  55. NSDictionary *loginInfo = [[UseAccountManage shareInstance] getLoginInfo];
  56. /*用户名*/
  57. UILabel *phoneLabel = [[UILabel alloc] init];
  58. [phoneLabel setFont:[UIFont boldSystemFontOfSize:18.f]];
  59. [phoneLabel setTextColor:[UIColor whiteColor]];
  60. if (loginInfo && [[loginInfo allKeys] containsObject:@"phone"]){
  61. [phoneLabel setText:[loginInfo objectForKey:@"phone"]];
  62. }
  63. [bgImView addSubview:phoneLabel];
  64. [phoneLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  65. make.left.equalTo(photoImage.mas_right).offset(9);
  66. make.centerY.equalTo(photoImage.mas_centerY);
  67. make.right.mas_equalTo(-22.f);
  68. make.height.mas_equalTo(25.f);
  69. }];
  70. /*下方会员视图*/
  71. // vip_bg
  72. UIImageView *downBgView = [[UIImageView alloc] init];
  73. [downBgView setImage:[UIImage imageNamed:@"vip_bg"]];
  74. [headView addSubview:downBgView];
  75. [downBgView mas_makeConstraints:^(MASConstraintMaker *make) {
  76. make.left.mas_equalTo(15.f);
  77. make.right.mas_equalTo(-15.f);
  78. make.bottom.mas_equalTo(-126.f);
  79. make.height.mas_equalTo(96.f);
  80. }];
  81. /*VIP类型*/
  82. UILabel *vipType = [[UILabel alloc] init];
  83. [vipType setText:@"VIP"];
  84. [vipType setTextColor:[UIColor whiteColor]];
  85. [vipType setFont:[UIFont boldSystemFontOfSize:24.f]];
  86. [downBgView addSubview:vipType];
  87. [vipType mas_makeConstraints:^(MASConstraintMaker *make) {
  88. make.left.mas_equalTo(20.f);
  89. make.right.mas_equalTo(-100.f);
  90. make.top.mas_equalTo(18.f);
  91. make.height.mas_equalTo(33.f);
  92. }];
  93. /*VIP类型提示*/
  94. UILabel *vipTypeTipsLabel = [[UILabel alloc] init];
  95. [vipTypeTipsLabel setText:@"你当前为非会员,无法享受专属私密手机"];
  96. [vipTypeTipsLabel setTextColor:[UIColor whiteColor]];
  97. [vipTypeTipsLabel setFont:[UIFont systemFontOfSize:12.f]];
  98. [downBgView addSubview:vipTypeTipsLabel];
  99. [vipTypeTipsLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  100. make.left.mas_equalTo(20.f);
  101. make.right.mas_equalTo(-100.f);
  102. make.top.mas_equalTo(53.f);
  103. make.height.mas_equalTo(17.f);
  104. }];
  105. /*免费会员按钮*/
  106. UIButton *vipBtn = [[UIButton alloc] init];
  107. [vipBtn setBackgroundColor:[UIColor whiteColor]];
  108. [vipBtn setTitle:@"免费领会员" forState:(UIControlStateNormal)];
  109. [vipBtn setTitleColor:HW0A132BColor forState:(UIControlStateNormal)];
  110. [vipBtn.titleLabel setFont:[UIFont systemFontOfSize:13.f]];
  111. [vipBtn.layer setCornerRadius:31.f/2.f];
  112. [downBgView addSubview:vipBtn];
  113. [vipBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  114. make.width.mas_equalTo(86.f);
  115. make.right.mas_equalTo(-20.f);
  116. make.centerY.equalTo(downBgView.mas_centerY);
  117. make.height.mas_equalTo(31.f);
  118. }];
  119. /*下方视图*/
  120. HelpDownScrollView *helpDownScrollView = [[HelpDownScrollView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W - 30, 96.f) withImageAry:@[@"icon-tubiao",@"icon-jincheng"] tilteAry:@[@"更换图标",@"进程隐藏"] numberOfLine:3];
  121. helpDownScrollView.presedDelegate = self;
  122. [headView addSubview:helpDownScrollView];
  123. [helpDownScrollView mas_makeConstraints:^(MASConstraintMaker *make) {
  124. make.left.mas_equalTo(15.f);
  125. make.right.mas_equalTo(-15.f);
  126. make.bottom.mas_equalTo(-15.f);
  127. make.height.mas_equalTo(96.f);
  128. }];
  129. [helpDownScrollView setBackgroundColor:[UIColor whiteColor]];
  130. [helpDownScrollView.layer setCornerRadius:8.f];
  131. return headView;
  132. }
  133. /*
  134. #pragma mark - Navigation
  135. // In a storyboard-based application, you will often want to do a little preparation before navigation
  136. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  137. // Get the new view controller using [segue destinationViewController].
  138. // Pass the selected object to the new view controller.
  139. }
  140. */
  141. - (void)helpDownScrollViewBePressed:(nonnull id)sender withIndex:(NSInteger)index {
  142. HLog(@"\n----点击了第个%ld按钮----",index);
  143. if (index == 0){
  144. ChangeLogoViewController *nextVC = [[ChangeLogoViewController alloc] init];
  145. [self.navigationController pushViewController:nextVC animated:YES];
  146. }
  147. }
  148. #pragma mark - 懒加载
  149. - (UITableView *)tableView{
  150. if (!_tableView) {
  151. _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, SCREEN_H - TABBARHEIGHT) style:UITableViewStyleGrouped];
  152. _tableView.delegate = self;
  153. _tableView.dataSource = self;
  154. _tableView.showsVerticalScrollIndicator = NO;
  155. _tableView.showsHorizontalScrollIndicator = NO;
  156. _tableView.contentInset = UIEdgeInsetsMake(-H_STATE_BAR, 0, 0, 0);
  157. [_tableView setSeparatorStyle:(UITableViewCellSeparatorStyleNone)];
  158. [_tableView setSeparatorColor:[UIColor clearColor]];
  159. [_tableView setBackgroundColor:[UIColor clearColor]];
  160. [_tableView setTableFooterView:[UIView new]];
  161. [_tableView setBounces:YES];
  162. if (@available(iOS 15.0, *)) {
  163. _tableView.sectionHeaderTopPadding = 0;
  164. }
  165. }
  166. return _tableView;
  167. }
  168. #pragma mark - 列表委托
  169. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  170. return 1;
  171. }
  172. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  173. return 5;
  174. }
  175. - (MineViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  176. NSInteger row = indexPath.row;
  177. static NSString *identifier = @"MineViewCell";
  178. MineViewCell * cell = [tableView dequeueReusableCellWithIdentifier:identifier];
  179. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  180. if (!cell){
  181. cell = [[MineViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:identifier];
  182. [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
  183. [cell setBackgroundColor:[UIColor clearColor]];
  184. [cell setAccessoryType:(UITableViewCellAccessoryNone)];
  185. }
  186. [cell.bgViewLayer removeFromSuperlayer];
  187. [cell.titleLabel2 setHidden:YES];
  188. [cell.rightImage setHidden:NO];
  189. [cell.lineView setHidden:NO];
  190. if (row == 0){
  191. [cell.titleLabel setText:@"邀请好友"];
  192. [cell.titleLabel2 setText:@"邀请好友送会员"];
  193. [cell.mImageView setImage:[UIImage imageNamed:@"icon-yaoqing"]];
  194. [cell.titleLabel2 setHidden:NO];
  195. /*上圆角*/
  196. //设置部分圆角 贝塞尔曲线
  197. UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, SCREEN_W-30 , 60)
  198. byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight
  199. cornerRadii:CGSizeMake(8, 8)];
  200. CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
  201. maskLayer.frame = cell.cellBgView.bounds;
  202. maskLayer.path = maskPath.CGPath;
  203. cell.bgViewLayer = maskLayer;
  204. cell.cellBgView.layer.mask = cell.bgViewLayer;
  205. }else if (row == 1){
  206. [cell.titleLabel setText:@"清除缓存"];
  207. [cell.titleLabel2 setText:@"0M"];
  208. [cell.titleLabel2 setHidden:NO];
  209. /*计算缓存大小*/
  210. [cell.mImageView setImage:[UIImage imageNamed:@"icon-qingchu"]];
  211. }else if (row == 2){
  212. [cell.titleLabel setText:@"检测更新"];
  213. [cell.mImageView setImage:[UIImage imageNamed:@"icon-gengxin"]];
  214. }else if (row == 3){
  215. [cell.titleLabel setText:@"联系客服"];
  216. [cell.mImageView setImage:[UIImage imageNamed:@"icon-kefu"]];
  217. }else if (row == 4){
  218. [cell.titleLabel setText:@"退出账号"];
  219. [cell.mImageView setImage:[UIImage imageNamed:@"icon-tuichu"]];
  220. [cell.rightImage setHidden:YES];
  221. /*下圆角*/
  222. UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, SCREEN_W-30 , 60)
  223. byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerBottomRight
  224. cornerRadii:CGSizeMake(8, 8)];
  225. CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
  226. maskLayer.frame = cell.cellBgView.bounds;
  227. maskLayer.path = maskPath.CGPath;
  228. cell.bgViewLayer = maskLayer;
  229. cell.cellBgView.layer.mask = cell.bgViewLayer;
  230. [cell.lineView setHidden:YES];
  231. }
  232. return cell;
  233. }
  234. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  235. return 60;
  236. }
  237. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  238. [tableView deselectRowAtIndexPath:indexPath animated:YES];
  239. NSInteger row = indexPath.row;
  240. }
  241. @end