cloudPhoneSetView.m 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. //
  2. // cloudPhoneSetView.m
  3. // Private-X
  4. //
  5. // Created by xd h on 2024/6/24.
  6. //
  7. #import "cloudPhoneSetView.h"
  8. @implementation cloudPhoneSetView
  9. - (id)initWithFrame:(CGRect)frame{
  10. self = [super initWithFrame:frame];
  11. self.backgroundColor = [UIColor hwColor:@"#000000" alpha:0.6];
  12. [self drawAnyView];
  13. return self;
  14. }
  15. -(void)drawAnyView
  16. {
  17. //大按钮响应
  18. UIButton *bigRightButton = [[UIButton alloc] init];
  19. bigRightButton.tag = 1;
  20. [bigRightButton addTarget:self action:@selector(didClickButtonFun:) forControlEvents:UIControlEventTouchUpInside];
  21. [self addSubview:bigRightButton];
  22. //bigRightButton.backgroundColor= [UIColor redColor];
  23. [bigRightButton mas_makeConstraints:^(MASConstraintMaker *make) {
  24. make.top.mas_equalTo(0);
  25. make.left.mas_equalTo(0);
  26. make.right.mas_equalTo(0);
  27. make.bottom.mas_equalTo(0);
  28. }];
  29. UIView *whiteBgView = [[UIView alloc] init];
  30. whiteBgView.backgroundColor = [UIColor whiteColor];
  31. [self addSubview:whiteBgView];
  32. whiteBgView.layer.cornerRadius = 8;
  33. whiteBgView.layer.masksToBounds = YES;
  34. CGFloat curWhiteWidth = 132.0;
  35. NSArray *arLanguages = [[NSUserDefaults standardUserDefaults] objectForKey:@"AppleLanguages"];
  36. NSLog(@"arLanguages:%@",arLanguages);
  37. ///获取设备当前地区的代码和APP语言环境
  38. NSString *languageCode = [NSLocale preferredLanguages][0];
  39. //目前支持 中文(简体 繁体) 英文 日语
  40. if([languageCode rangeOfString:@"zh-Hans"].location != NSNotFound)
  41. {
  42. }
  43. else if([languageCode rangeOfString:@"zh-Hant"].location != NSNotFound)
  44. {
  45. }
  46. else{
  47. curWhiteWidth = 172;
  48. }
  49. [whiteBgView mas_makeConstraints:^(MASConstraintMaker *make) {
  50. make.top.mas_equalTo(100);
  51. make.right.mas_equalTo(-12);
  52. make.width.mas_equalTo(curWhiteWidth);
  53. //make.width.mas_equalTo(132);
  54. make.height.mas_equalTo(100);
  55. //make.height.mas_equalTo(150);
  56. }];
  57. NSArray *butImageArr = @[//@"cloudPhone_uploadApp",
  58. @"cloudPhone_reStart",@"cloudPhone_reset"];
  59. NSArray *butTextArr = @[//NSLocalizedString(@"cloudPhone_upload_app",nil),
  60. NSLocalizedString(@"my_set_no_restart_phone",nil),
  61. NSLocalizedString(@"my_set_no_Restore_Factory",nil)];
  62. CGFloat butHeight = 50.0;
  63. for (int i=0; i<butImageArr.count; i++) {
  64. UIButton *but = [[UIButton alloc] init];
  65. but.tag = 10+i;
  66. [but addTarget:self action:@selector(didClickButtonFun:) forControlEvents:UIControlEventTouchUpInside];
  67. NSString *butTitle = [[NSString alloc] initWithFormat:@" %@",butTextArr[i]];
  68. [but setImage:[UIImage imageNamed:butImageArr[i]] forState:UIControlStateNormal];
  69. [but setTitle:butTitle forState:UIControlStateNormal];
  70. [but setTitleColor:[UIColor hwColor:@"#0A132B"] forState:UIControlStateNormal];
  71. but.titleLabel.font = [UIFont systemFontOfSize:14.0];
  72. [whiteBgView addSubview:but];
  73. [but mas_makeConstraints:^(MASConstraintMaker *make) {
  74. make.left.mas_equalTo(0);
  75. make.right.mas_equalTo(0);
  76. make.height.mas_equalTo(butHeight);
  77. make.top.mas_equalTo(butHeight*i);
  78. }];
  79. if(i != butImageArr.count -1){
  80. UIView *lineV = [UIView new];
  81. lineV.backgroundColor = [UIColor hwColor:@"#F3F5F9"];
  82. [whiteBgView addSubview:lineV];
  83. [lineV mas_makeConstraints:^(MASConstraintMaker *make) {
  84. make.left.mas_equalTo(8);
  85. make.right.mas_equalTo(-8);
  86. make.height.mas_equalTo(0.5);
  87. make.top.mas_equalTo(butHeight*(i+1));
  88. }];
  89. }
  90. }
  91. }
  92. #pragma mark 按钮事件
  93. - (void)didClickButtonFun:(UIButton*)but
  94. {
  95. NSInteger tag = but.tag;
  96. HLog(@"%ld",tag);
  97. [self removeFun];
  98. if(tag == 1){
  99. return;
  100. }
  101. if(_didClickButtonFun){
  102. _didClickButtonFun(tag);
  103. }
  104. }
  105. - (void)removeFun
  106. {
  107. [self removeFromSuperview];
  108. }
  109. @end