PreferencesViewController.m 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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 80
  10. #define ProgressH 4
  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)UITableView *tableview;
  20. @end
  21. @implementation PreferencesViewController
  22. -(void)viewDidLoad{
  23. [super viewDidLoad];
  24. }
  25. -(void)initSubViews{
  26. //|----|namelabel
  27. //|头像 |progress
  28. //|____|descritionlabel
  29. CGFloat screenW = SCREEN_WIDTH;
  30. CGFloat residualRightW;
  31. CGFloat residualRightH;
  32. UIImageView *avatarview = [[UIImageView alloc]init];
  33. avatarview.layer.cornerRadius = AvatarWH/2;
  34. avatarview.layer.masksToBounds = YES;
  35. avatarview.frame = CGRectMake(ScreenMarginTBLR, ScreenMarginTBLR, AvatarWH, AvatarWH);
  36. avatarview.backgroundColor = [UIColor grayColor];
  37. [self.view addSubview:avatarview];
  38. self.avatarview = avatarview;
  39. residualRightW = screenW - MaxX(avatarview) - 10 - 20;//10 为何下一个控件的x距离 20为右边距
  40. UILabel *namelab = [[UILabel alloc]init];
  41. namelab.textColor = [UIColor blackColor];
  42. namelab.font = [UIFont boldSystemFontOfSize:18];
  43. namelab.text = [userDefaults objectForKey:@"displayName"];
  44. namelab.frame = CGRectMake(MaxX(avatarview)+ 10, ScreenMarginTBLR, 200, 30);//临时写死
  45. [self.view addSubview:namelab];
  46. UIProgressView *progressview = [[UIProgressView alloc]initWithFrame:CGRectMake(screenW-residualRightW,avatarview.centerY -2 , residualRightW, ProgressH)];
  47. progressview.progressTintColor = UIColorFromRGB(0x0DA32E);
  48. progressview.backgroundColor = [UIColor lightGrayColor];
  49. [self.view addSubview:progressview];
  50. self.progressview = progressview;
  51. UILabel *descritionlab = [[UILabel alloc]init];
  52. descritionlab.text = @"容量 (23.12G/35.00G 66%)";
  53. [self.view addSubview:descritionlab];
  54. }
  55. @end