mySetHeadView.m 21 KB

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