PreferencesViewController.m 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. //
  2. // PreferencesViewController.m
  3. // WSCloudStorage
  4. //
  5. // Created by JonathanH on 2017/8/2.
  6. // Copyright © 2017年 wswinsoft. All rights reserved.
  7. //
  8. #import "PreferencesViewController.h"
  9. #define AvatarWH 60
  10. #define ProgressH 8
  11. #define MaxX(view) CGRectGetMaxX(view.frame)
  12. #define EqualY(view) view.frame.origin.y
  13. //#define MaxXPlus(MaxX(v),plusnumber) (MaxX(v) + plusnumber)
  14. //Avatar frame
  15. #define ScreenMarginTBLR 20
  16. @interface PreferencesViewController()<UITableViewDelegate,UITableViewDataSource>
  17. @property(nonatomic,weak)UIImageView *avatarview;
  18. @property(nonatomic,weak)UIProgressView *progressview;
  19. @property(nonatomic,weak)UIView *gridView;//九宫格view,待自定义
  20. @property(nonatomic,weak)UITableView *tableview;
  21. @end
  22. @implementation PreferencesViewController
  23. -(void)viewDidLoad{
  24. [super viewDidLoad];
  25. self.navigationController.navigationBar.hidden = YES;
  26. [self initSubViews];
  27. }
  28. -(void)initSubViews{
  29. //|----|namelabel
  30. //|头像 |progress
  31. //|____|descritionlabel
  32. CGFloat screenW = SCREEN_WIDTH;
  33. CGFloat residualRightW;
  34. CGFloat residualRightH;
  35. UIImageView *avatarview = [[UIImageView alloc]init];
  36. avatarview.layer.cornerRadius = AvatarWH/2;
  37. avatarview.layer.masksToBounds = YES;
  38. avatarview.frame = CGRectMake(ScreenMarginTBLR, 2*ScreenMarginTBLR, AvatarWH, AvatarWH);
  39. avatarview.backgroundColor = [UIColor grayColor];
  40. [self.view addSubview:avatarview];
  41. self.avatarview = avatarview;
  42. residualRightW = screenW - MaxX(avatarview) - 10 - 20;//10 为何下一个控件的x距离 20为右边距
  43. UILabel *namelab = [[UILabel alloc]init];
  44. namelab.backgroundColor = [UIColor grayColor];
  45. namelab.textColor = [UIColor blackColor];
  46. namelab.font = [UIFont systemFontOfSize:16];
  47. namelab.text = [userDefaults objectForKey:@"displayName"]==nil?@"显示名称":[userDefaults objectForKey:@"displayName"];
  48. namelab.frame = CGRectMake(MaxX(avatarview)+ 10, avatarview.frame.origin.y, 200, 30);//临时写死
  49. [self.view addSubview:namelab];
  50. UIProgressView *progressview = [[UIProgressView alloc]initWithFrame:CGRectMake(namelab.origin.x,avatarview.centerY -ProgressH/2 , residualRightW, ProgressH)];
  51. progressview.progressTintColor = UIColorFromRGB(0x0DA32E);
  52. progressview.backgroundColor = [UIColor lightGrayColor];
  53. [self.view addSubview:progressview];
  54. self.progressview = progressview;
  55. UILabel *descritionlab = [[UILabel alloc]init];
  56. descritionlab.text = @"容量 (23.12G/35.00G 66%)";
  57. descritionlab.font = [UIFont systemFontOfSize:12];
  58. descritionlab.backgroundColor = [UIColor grayColor];
  59. descritionlab.frame = CGRectMake(progressview.origin.x, CGRectGetMaxY(progressview.frame), residualRightW, 30);
  60. [self.view addSubview:descritionlab];
  61. UIView *gridView = [[UIView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(avatarview.frame)+20, screenW, 200)];
  62. gridView.backgroundColor = [UIColor blueColor];
  63. [self.view addSubview:gridView];
  64. self.gridView = gridView;
  65. UITableView *tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(gridView.frame), screenW, 300) style:UITableViewStylePlain];
  66. tableView.separatorColor = [UIColor clearColor];
  67. [self.view addSubview:tableView];
  68. self.tableview = tableView;
  69. }
  70. @end