mySetHeadView.m 21 KB

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