mySetHeadView.m 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543
  1. //
  2. // mySetHeadView.m
  3. // 隐私保护
  4. //
  5. // Created by xd h on 2023/11/9.
  6. //
  7. #import "mySetHeadView.h"
  8. #import "TZImageManager.h"
  9. #import "backupsFileManager.h"
  10. @interface mySetHeadView ()
  11. {
  12. UIView *imageBackupsBgView;
  13. UILabel *imageBackupsLabel;
  14. }
  15. @end
  16. @implementation mySetHeadView
  17. - (id)initWithFrame:(CGRect)frame{
  18. self = [super initWithFrame:frame];
  19. [self drawAnyView];
  20. [self setBackupsStateFun];
  21. return self;
  22. }
  23. - (void)drawAnyView{
  24. [self setBackgroundColor:[UIColor hwColor:@"#F5F7FA" alpha:1.0]];
  25. //self.backgroundColor = [UIColor redColor];
  26. //setting_Privacy_bg
  27. UIImageView *PrivacyBg = [[UIImageView alloc] init];
  28. PrivacyBg.image = [UIImage imageNamed:@"setting_Privacy_bg"];
  29. //PrivacyBg.contentMode = UIViewContentModeScaleAspectFit;
  30. PrivacyBg.userInteractionEnabled = YES;
  31. [self addSubview:PrivacyBg];
  32. //PrivacyBg.backgroundColor = [UIColor greenColor];
  33. CGFloat PrivacyBgW = SCREEN_W - 20;
  34. CGFloat PrivacyBgH = 116.0 * PrivacyBgW / (345.0);
  35. [PrivacyBg mas_makeConstraints:^(MASConstraintMaker *make) {
  36. make.left.mas_equalTo(10);
  37. make.top.mas_equalTo(10);
  38. make.width.mas_equalTo(PrivacyBgW);
  39. make.height.mas_equalTo(PrivacyBgH);
  40. }];
  41. UILabel *PrivacyTitleLabel = [[UILabel alloc] init];
  42. PrivacyTitleLabel.text = NSLocalizedString(@"my_set_Privacy_Model",nil) ;
  43. PrivacyTitleLabel.font = [UIFont boldSystemFontOfSize:16.0];
  44. PrivacyTitleLabel.textColor = [UIColor hwColor:@"0A132B" alpha:1.0];
  45. [PrivacyBg addSubview:PrivacyTitleLabel];
  46. [PrivacyTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  47. make.left.mas_equalTo(10);
  48. make.top.mas_equalTo(15);
  49. make.width.mas_equalTo(150);
  50. make.height.mas_equalTo(20);
  51. }];
  52. UIButton *setPrivacyBut = [[UIButton alloc] init];
  53. // gradient
  54. CAGradientLayer *gl = [CAGradientLayer layer];
  55. gl.frame = CGRectMake(0,0,80.f,32.f);
  56. gl.startPoint = CGPointMake(0, 0.5);
  57. gl.endPoint = CGPointMake(1, 0.5);
  58. gl.colors = @[(__bridge id)HW0CDEFDColor.CGColor, (__bridge id)HW058DFBColor.CGColor];
  59. gl.locations = @[@(0), @(1.0f)];
  60. [setPrivacyBut.layer addSublayer:gl];
  61. setPrivacyBut.tag = 4;
  62. [setPrivacyBut addTarget:self action:@selector(didClickButFun:) forControlEvents:UIControlEventTouchUpInside];
  63. setPrivacyBut.layer.cornerRadius = 16.0;
  64. setPrivacyBut.layer.masksToBounds = YES;
  65. [setPrivacyBut setTitle:NSLocalizedString(@"set_Privacy_button_title",nil) forState:UIControlStateNormal];
  66. setPrivacyBut.titleLabel.font = [UIFont systemFontOfSize:12.0];
  67. [PrivacyBg addSubview:setPrivacyBut];
  68. [setPrivacyBut mas_makeConstraints:^(MASConstraintMaker *make) {
  69. make.right.mas_equalTo(-10);
  70. make.top.mas_equalTo(10);
  71. make.width.mas_equalTo(80);
  72. make.height.mas_equalTo(32);
  73. }];
  74. UILabel *PrivacyTipLabel = [[UILabel alloc] init];
  75. PrivacyTipLabel.text = NSLocalizedString(@"set_Privacy_Tip",nil) ;
  76. PrivacyTipLabel.font = [UIFont systemFontOfSize:14.0];
  77. PrivacyTipLabel.textColor = [UIColor hwColor:@"#01B7EA" alpha:1.0];
  78. [PrivacyBg addSubview:PrivacyTipLabel];
  79. [PrivacyTipLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  80. make.left.mas_equalTo(10);
  81. make.top.mas_equalTo(PrivacyTitleLabel.mas_bottom).offset(10);
  82. make.right.mas_equalTo(0);
  83. make.height.mas_equalTo(20);
  84. }];
  85. UILabel *PrivacyTipLabel2 = [[UILabel alloc] init];
  86. PrivacyTipLabel2.text = NSLocalizedString(@"my_set_Privacy_Mode_tip1",nil) ;
  87. PrivacyTipLabel2.font = [UIFont systemFontOfSize:12.0];
  88. PrivacyTipLabel2.textColor = [UIColor hwColor:@"#6A6A6A" alpha:1.0];
  89. PrivacyTipLabel2.numberOfLines = 0;
  90. [PrivacyBg addSubview:PrivacyTipLabel2];
  91. [PrivacyTipLabel2 mas_makeConstraints:^(MASConstraintMaker *make) {
  92. make.left.mas_equalTo(10);
  93. make.top.mas_equalTo(PrivacyTipLabel.mas_bottom).offset(10);
  94. make.right.mas_equalTo(-10);
  95. make.height.mas_equalTo(40);
  96. }];
  97. //文件上传
  98. UIView *fileUploadBgView = [[UIView alloc] init];
  99. fileUploadBgView.backgroundColor = [UIColor whiteColor];
  100. fileUploadBgView.layer.cornerRadius = 8;
  101. [self addSubview:fileUploadBgView];
  102. [fileUploadBgView mas_makeConstraints:^(MASConstraintMaker *make) {
  103. make.left.mas_equalTo(10);
  104. make.top.mas_equalTo(PrivacyBg.mas_bottom).offset(15);
  105. make.right.mas_equalTo(-10);
  106. make.height.mas_equalTo(110);
  107. }];
  108. UILabel *titleLabel = [[UILabel alloc] init];
  109. titleLabel.text = NSLocalizedString(@"my_set_no_File_upload_title",nil) ;
  110. titleLabel.font = [UIFont boldSystemFontOfSize:16.0];
  111. [fileUploadBgView addSubview:titleLabel];
  112. [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  113. make.left.mas_equalTo(10);
  114. make.top.mas_equalTo(10);
  115. make.width.mas_equalTo(100);
  116. make.height.mas_equalTo(20);
  117. }];
  118. //上传记录
  119. UIImageView *arrowImageView = [[UIImageView alloc] init];
  120. arrowImageView.image = [UIImage imageNamed:@"cell_right_access"];
  121. [fileUploadBgView addSubview:arrowImageView];
  122. [arrowImageView mas_makeConstraints:^(MASConstraintMaker *make) {
  123. make.right.mas_equalTo(-10);
  124. make.top.mas_equalTo(10);
  125. make.width.mas_equalTo(20);
  126. make.height.mas_equalTo(20);
  127. }];
  128. UILabel *rightLabel = [[UILabel alloc] init];
  129. rightLabel.text = NSLocalizedString(@"set_upload_download_tip",nil) ;
  130. rightLabel.font = [UIFont systemFontOfSize:14.0];
  131. rightLabel.textColor = [UIColor hwColor:@"#959799" alpha:1.0];
  132. rightLabel.textAlignment = NSTextAlignmentRight;
  133. [fileUploadBgView addSubview:rightLabel];
  134. [rightLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  135. make.right.mas_equalTo(arrowImageView.mas_left).offset(-2);
  136. make.top.mas_equalTo(10);
  137. make.width.mas_equalTo(200);
  138. make.height.mas_equalTo(20);
  139. }];
  140. UIButton *recordBut = [[UIButton alloc] init];
  141. //recordBut.backgroundColor = [UIColor greenColor];
  142. recordBut.tag = 1;
  143. [recordBut addTarget:self action:@selector(didClickButFun:) forControlEvents:UIControlEventTouchUpInside];
  144. [fileUploadBgView addSubview:recordBut];
  145. [recordBut mas_makeConstraints:^(MASConstraintMaker *make) {
  146. make.right.mas_equalTo(0);
  147. make.top.mas_equalTo(0);
  148. make.width.mas_equalTo(150);
  149. make.height.mas_equalTo(40);
  150. }];
  151. arrowImageView.hidden = YES;
  152. rightLabel.hidden = YES;
  153. recordBut.hidden = YES;
  154. //图片上传
  155. NSString* curImgUploadStr = [[NSString alloc] initWithFormat:@"%@ %@",@" ",NSLocalizedString(@"my_set_no_image_upload",nil)];
  156. UIButton *imageUploadBut = [[UIButton alloc] init];
  157. [imageUploadBut setImage:[UIImage imageNamed:@"icon_image_upload"] forState:UIControlStateNormal];
  158. [imageUploadBut setTitle:curImgUploadStr forState:UIControlStateNormal];
  159. imageUploadBut.backgroundColor = [UIColor hwColor:@"#00D1C1" alpha:0.1];
  160. imageUploadBut.layer.cornerRadius = 4;
  161. [imageUploadBut setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
  162. imageUploadBut.titleLabel.font = [UIFont systemFontOfSize:13.0];
  163. imageUploadBut.tag = 2;
  164. [imageUploadBut addTarget:self action:@selector(didClickButFun:) forControlEvents:UIControlEventTouchUpInside];
  165. [fileUploadBgView addSubview:imageUploadBut];
  166. [imageUploadBut mas_makeConstraints:^(MASConstraintMaker *make) {
  167. make.left.mas_equalTo(10);
  168. make.right.mas_equalTo(self.mas_centerX).offset(-10);
  169. make.bottom.mas_equalTo(-10);
  170. make.height.mas_equalTo(48);
  171. }];
  172. //视频上传
  173. NSString* curVidelUploadStr = [[NSString alloc] initWithFormat:@"%@ %@",@" ",NSLocalizedString(@"my_set_no_video_upload",nil)];
  174. UIButton *videoUploadBut = [[UIButton alloc] init];
  175. [videoUploadBut setImage:[UIImage imageNamed:@"icon_video_upload"] forState:UIControlStateNormal];
  176. [videoUploadBut setTitle:curVidelUploadStr forState:UIControlStateNormal];
  177. videoUploadBut.backgroundColor = [UIColor hwColor:@"#00D8FF" alpha:0.1];
  178. videoUploadBut.layer.cornerRadius = 4;
  179. [videoUploadBut setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
  180. videoUploadBut.titleLabel.font = [UIFont systemFontOfSize:13.0];
  181. videoUploadBut.tag = 3;
  182. [videoUploadBut addTarget:self action:@selector(didClickButFun:) forControlEvents:UIControlEventTouchUpInside];
  183. [fileUploadBgView addSubview:videoUploadBut];
  184. [videoUploadBut mas_makeConstraints:^(MASConstraintMaker *make) {
  185. make.right.mas_equalTo(-10);
  186. make.left.mas_equalTo(self.mas_centerX).offset(10);
  187. make.bottom.mas_equalTo(-10);
  188. make.height.mas_equalTo(48);
  189. }];
  190. //文件备份
  191. UIView *fileBackupsBgView = [[UIView alloc] init];
  192. fileBackupsBgView.backgroundColor = [UIColor whiteColor];
  193. fileBackupsBgView.layer.cornerRadius = 8;
  194. [self addSubview:fileBackupsBgView];
  195. [fileBackupsBgView mas_makeConstraints:^(MASConstraintMaker *make) {
  196. make.left.mas_equalTo(10);
  197. make.top.mas_equalTo(fileUploadBgView.mas_bottom).offset(15);
  198. make.right.mas_equalTo(-10);
  199. make.height.mas_equalTo(110);
  200. }];
  201. UILabel *BackupsTitleLabel = [[UILabel alloc] init];
  202. BackupsTitleLabel.text = NSLocalizedString(@"set_Privacy_title",nil) ;
  203. BackupsTitleLabel.font = [UIFont boldSystemFontOfSize:16.0];
  204. [fileBackupsBgView addSubview:BackupsTitleLabel];
  205. [BackupsTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  206. make.left.mas_equalTo(10);
  207. make.top.mas_equalTo(10);
  208. make.width.mas_equalTo(100);
  209. make.height.mas_equalTo(20);
  210. }];
  211. //
  212. UIImageView *arrowImageView2 = [[UIImageView alloc] init];
  213. arrowImageView2.image = [UIImage imageNamed:@"cell_right_access"];
  214. [fileBackupsBgView addSubview:arrowImageView2];
  215. [arrowImageView2 mas_makeConstraints:^(MASConstraintMaker *make) {
  216. make.right.mas_equalTo(-10);
  217. make.top.mas_equalTo(10);
  218. make.width.mas_equalTo(20);
  219. make.height.mas_equalTo(20);
  220. }];
  221. NSString *BackupsRightTitle = NSLocalizedString(@"set_Privacy_right_tip",nil);
  222. CGFloat BackupsRightW = [BackupsRightTitle boundingRectWithSize:CGSizeMake(200, 20) options:(NSStringDrawingUsesLineFragmentOrigin) attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:14.0]} context:nil].size.width;
  223. BackupsRightW += 5;
  224. UILabel *BackupsRightLabel = [[UILabel alloc] init];
  225. BackupsRightLabel.text = BackupsRightTitle;
  226. BackupsRightLabel.font = [UIFont systemFontOfSize:14.0];
  227. BackupsRightLabel.textColor = [UIColor hwColor:@"#959799" alpha:1.0];
  228. BackupsRightLabel.textAlignment = NSTextAlignmentRight;
  229. [fileBackupsBgView addSubview:BackupsRightLabel];
  230. [BackupsRightLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  231. make.right.mas_equalTo(arrowImageView.mas_left).offset(-2);
  232. make.top.mas_equalTo(10);
  233. make.width.mas_equalTo(BackupsRightW);
  234. make.height.mas_equalTo(20);
  235. }];
  236. UIButton *BackupsSetBut = [[UIButton alloc] init];
  237. //BackupsSetBut.backgroundColor = [UIColor greenColor];
  238. BackupsSetBut.tag = 5;
  239. [BackupsSetBut addTarget:self action:@selector(didClickButFun:) forControlEvents:UIControlEventTouchUpInside];
  240. [fileBackupsBgView addSubview:BackupsSetBut];
  241. [BackupsSetBut mas_makeConstraints:^(MASConstraintMaker *make) {
  242. make.right.mas_equalTo(0);
  243. make.top.mas_equalTo(0);
  244. make.left.mas_equalTo(BackupsRightLabel.mas_left);
  245. make.height.mas_equalTo(40);
  246. }];
  247. // arrowImageView2.hidden = YES;
  248. // BackupsRightLabel.hidden = YES;
  249. // BackupsSetBut.hidden = YES;
  250. UIButton *BackupsEyeBut = [[UIButton alloc] init];
  251. //BackupsEyeBut.backgroundColor = [UIColor greenColor];
  252. [BackupsEyeBut setImage:[UIImage imageNamed:@"common_eye_open"] forState:UIControlStateNormal];
  253. [BackupsEyeBut setImage:[UIImage imageNamed:@"common_eye_close"] forState:UIControlStateSelected];
  254. BackupsEyeBut.tag = 6;
  255. [BackupsEyeBut addTarget:self action:@selector(didClickButFun:) forControlEvents:UIControlEventTouchUpInside];
  256. [fileBackupsBgView addSubview:BackupsEyeBut];
  257. [BackupsEyeBut mas_makeConstraints:^(MASConstraintMaker *make) {
  258. make.right.mas_equalTo(BackupsSetBut.mas_left).offset(0);
  259. make.centerY.mas_equalTo(BackupsRightLabel.mas_centerY);
  260. make.width.mas_equalTo(40);
  261. make.height.mas_equalTo(40);
  262. }];
  263. BackupsEyeBut.hidden = YES;
  264. imageBackupsBgView = [[UIView alloc] init];
  265. imageBackupsBgView.backgroundColor = [UIColor hwColor:@"#F9F9F9" alpha:1.0];
  266. imageBackupsBgView.layer.cornerRadius = 8;
  267. [fileBackupsBgView addSubview:imageBackupsBgView];
  268. [imageBackupsBgView mas_makeConstraints:^(MASConstraintMaker *make) {
  269. make.right.mas_equalTo(-10);
  270. make.left.mas_equalTo(10);
  271. make.bottom.mas_equalTo(-10);
  272. make.height.mas_equalTo(56);
  273. }];
  274. UIImageView *backupsImageV = [[UIImageView alloc] init];
  275. backupsImageV.image = [UIImage imageNamed:@"image_backups_icon"];
  276. [imageBackupsBgView addSubview:backupsImageV];
  277. [backupsImageV mas_makeConstraints:^(MASConstraintMaker *make) {
  278. make.centerY.mas_equalTo(0);
  279. make.left.mas_equalTo(10);
  280. make.width.mas_equalTo(28);
  281. make.height.mas_equalTo(28);
  282. }];
  283. UILabel *imageBackupsTitleLabel = [[UILabel alloc] init];
  284. imageBackupsTitleLabel.text = NSLocalizedString(@"set_Privacy_title_image",nil) ;
  285. imageBackupsTitleLabel.font = [UIFont systemFontOfSize:14.0];
  286. [imageBackupsBgView addSubview:imageBackupsTitleLabel];
  287. [imageBackupsTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  288. make.centerY.mas_equalTo(-10);
  289. make.left.mas_equalTo(backupsImageV.mas_right).offset(10);
  290. make.width.mas_equalTo(100);
  291. make.height.mas_equalTo(20);
  292. }];
  293. _imageBackupsLabel = [[UILabel alloc] init];
  294. //_imageBackupsLabel.text = NSLocalizedString(@"set_Privacy_title_image_open",nil) ;
  295. _imageBackupsLabel.font = [UIFont systemFontOfSize:12.0];
  296. _imageBackupsLabel.textColor = [UIColor hwColor:@"#6A6A6A" alpha:1.0];
  297. [imageBackupsBgView addSubview:_imageBackupsLabel];
  298. [_imageBackupsLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  299. make.centerY.mas_equalTo(10);
  300. make.left.mas_equalTo(backupsImageV.mas_right).offset(10);
  301. make.width.mas_equalTo(100);
  302. make.height.mas_equalTo(20);
  303. }];
  304. _imageBackupsButton = [[UIButton alloc] init];
  305. _imageBackupsButton.backgroundColor = [UIColor hwColor:@"#DCF4FB" alpha:1.0];
  306. _imageBackupsButton.tag = 7;
  307. [_imageBackupsButton addTarget:self action:@selector(didClickButFun:) forControlEvents:UIControlEventTouchUpInside];
  308. _imageBackupsButton.layer.cornerRadius = 12.0;
  309. _imageBackupsButton.layer.masksToBounds = YES;
  310. [_imageBackupsButton setTitle:NSLocalizedString(@"common_open",nil) forState:UIControlStateNormal];
  311. [_imageBackupsButton setTitle:NSLocalizedString(@"common_close",nil) forState:UIControlStateSelected];
  312. [_imageBackupsButton setTitleColor:[UIColor hwColor:@"#01B7EA" alpha:1.0] forState:UIControlStateNormal];
  313. _imageBackupsButton.titleLabel.font = [UIFont systemFontOfSize:12.0];
  314. [imageBackupsBgView addSubview:_imageBackupsButton];
  315. [_imageBackupsButton mas_makeConstraints:^(MASConstraintMaker *make) {
  316. make.right.mas_equalTo(-10);
  317. make.centerY.mas_equalTo(0);
  318. make.width.mas_equalTo(60);
  319. make.height.mas_equalTo(24);
  320. }];
  321. //其他功能
  322. UIView *otherBgView = [[UIView alloc] init];
  323. otherBgView.backgroundColor = [UIColor whiteColor];
  324. otherBgView.layer.cornerRadius = 8;
  325. [self addSubview:otherBgView];
  326. [otherBgView mas_makeConstraints:^(MASConstraintMaker *make) {
  327. make.left.mas_equalTo(10);
  328. make.top.mas_equalTo(fileBackupsBgView.mas_bottom).offset(15);
  329. make.right.mas_equalTo(-10);
  330. make.height.mas_equalTo(135);
  331. }];
  332. UILabel *otherTitleLabel = [[UILabel alloc] init];
  333. otherTitleLabel.text = NSLocalizedString(@"set_other_title",nil) ;
  334. otherTitleLabel.font = [UIFont boldSystemFontOfSize:16.0];
  335. [otherBgView addSubview:otherTitleLabel];
  336. [otherTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  337. make.left.mas_equalTo(10);
  338. make.top.mas_equalTo(10);
  339. make.width.mas_equalTo(100);
  340. make.height.mas_equalTo(20);
  341. }];
  342. NSArray *titleArr = @[NSLocalizedString(@"my_set_no_change_phone",nil),
  343. NSLocalizedString(@"my_set_no_restart_phone",nil),
  344. NSLocalizedString(@"my_set_no_Restore_Factory",nil),
  345. NSLocalizedString(@"my_set_no_common_problem",nil),
  346. NSLocalizedString(@"my_set_no_check_update",nil)];
  347. NSArray *imageArr = @[@"icon_change_ohone",@"icon-gengxin",@"icon_Restore_Factory",@"icon_common_problem",@"app_update"];
  348. CGFloat butWidth = (SCREEN_W -20)/titleArr.count;
  349. CGFloat butHeight = 88.0;
  350. for (int i=0; i<titleArr.count; i++) {
  351. UILabel *curlab = [[UILabel alloc] init];
  352. curlab.text = titleArr[i];
  353. curlab.font = [UIFont systemFontOfSize:12.0];
  354. curlab.textColor = [UIColor hwColor:@"#0A132B" alpha:1.0];
  355. curlab.numberOfLines = 0;
  356. curlab.textAlignment = NSTextAlignmentCenter;
  357. [otherBgView addSubview:curlab];
  358. [curlab mas_makeConstraints:^(MASConstraintMaker *make) {
  359. make.left.mas_equalTo(butWidth*i);
  360. make.bottom.mas_equalTo(-10);
  361. make.width.mas_equalTo(butWidth);
  362. make.height.mas_equalTo(30);
  363. }];
  364. UIButton *curImageV = [[UIButton alloc] init];
  365. curImageV.userInteractionEnabled = NO;
  366. [curImageV setImage:[UIImage imageNamed:imageArr[i]] forState:UIControlStateNormal];;
  367. [otherBgView addSubview:curImageV];
  368. [curImageV mas_makeConstraints:^(MASConstraintMaker *make) {
  369. make.left.mas_equalTo(butWidth*i);
  370. make.bottom.mas_equalTo(curlab.mas_top);
  371. make.width.mas_equalTo(butWidth);
  372. make.height.mas_equalTo(40);
  373. }];
  374. UIButton *curButton = [[UIButton alloc] init];
  375. //curButton.backgroundColor = [UIColor greenColor];
  376. curButton.tag = 10 + i;
  377. [curButton addTarget:self action:@selector(didClickButFun:) forControlEvents:UIControlEventTouchUpInside];
  378. //[curButton setTitle:titleArr[i] forState:UIControlStateNormal];
  379. //[curButton setTitleColor:[UIColor hwColor:@"#0A132B" alpha:1.0] forState:UIControlStateNormal];
  380. //[curButton setImage:[UIImage imageNamed:imageArr[i]] forState:UIControlStateNormal];
  381. //curButton.titleLabel.font = [UIFont systemFontOfSize:12.0];
  382. [otherBgView addSubview:curButton];
  383. [curButton mas_makeConstraints:^(MASConstraintMaker *make) {
  384. make.left.mas_equalTo(butWidth*i);
  385. make.bottom.mas_equalTo(0);
  386. make.width.mas_equalTo(butWidth);
  387. make.height.mas_equalTo(butHeight);
  388. }];
  389. }
  390. }
  391. - (void)closeImageBackupsFun
  392. {
  393. [HWDataManager setBoolWithKey:Const_photo_backups_state value:NO];
  394. [self setBackupsStateFun];
  395. //处理相册备份
  396. [[backupsFileManager shareInstance] suspendBackupsFileFun];
  397. }
  398. - (void)openImageBackupsFun
  399. {
  400. [HWDataManager setBoolWithKey:Const_photo_backups_state value:YES];
  401. [self setBackupsStateFun];
  402. [[iToast makeText:NSLocalizedString(@"set_Privacy_title_image_open",nil)] show];
  403. //处理相册备份
  404. [[backupsFileManager shareInstance] handlePhotosBackupsFun];
  405. }
  406. - (void)setBackupsStateFun
  407. {
  408. BOOL haveOpenBackups = [HWDataManager getBoolWithKey:Const_photo_backups_state];
  409. _imageBackupsButton.selected = haveOpenBackups;
  410. if(haveOpenBackups){
  411. _imageBackupsLabel.text = NSLocalizedString(@"set_Privacy_title_image_open",nil) ;
  412. }
  413. else
  414. {
  415. _imageBackupsLabel.text = NSLocalizedString(@"set_Privacy_title_image_close",nil) ;
  416. }
  417. }
  418. #pragma mark 按钮点击事件
  419. - (void)didClickButFun:(UIButton*)but
  420. {
  421. NSInteger tag = but.tag;
  422. //HLog(@"xxxx:%ld",tag)
  423. if(tag == 7){
  424. BOOL haveOpenBackups = [HWDataManager getBoolWithKey:Const_photo_backups_state];
  425. if(!haveOpenBackups){
  426. //相册权限
  427. if (![[TZImageManager manager] authorizationStatusAuthorized]){
  428. [PHPhotoLibrary requestAuthorization:^(PHAuthorizationStatus status) {
  429. if(status == PHAuthorizationStatusAuthorized){
  430. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  431. [self openImageBackupsFun];
  432. });
  433. }
  434. }];
  435. }
  436. else{
  437. [self openImageBackupsFun];
  438. }
  439. return;
  440. }
  441. }
  442. if(_didClickBut){
  443. _didClickBut(tag);
  444. }
  445. }
  446. @end