mySetHeadView.m 21 KB

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