imageVersionUpdateFailView.m 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. //
  2. // imageVersionUpdateFailView.m
  3. // 双子星云手机
  4. //
  5. // Created by xd h on 2024/12/31.
  6. //
  7. #import "imageVersionUpdateFailView.h"
  8. @implementation imageVersionUpdateFailView
  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. UIView*whiteBgView = [UIView new];
  17. whiteBgView.layer.cornerRadius = 8;
  18. whiteBgView.backgroundColor = [UIColor whiteColor];
  19. [self addSubview:whiteBgView];
  20. CGFloat curWhiteBgHeight = 400.f;
  21. ///获取设备当前地区的代码和APP语言环境
  22. NSString *languageCode = [NSLocale preferredLanguages][0];
  23. //目前支持 中文(简体 繁体) 英文 日语
  24. if([languageCode rangeOfString:@"zh-Hans"].location != NSNotFound)
  25. {
  26. }
  27. else if([languageCode rangeOfString:@"zh-Hant"].location != NSNotFound)
  28. {
  29. }
  30. else{
  31. curWhiteBgHeight = 500;
  32. }
  33. [whiteBgView mas_makeConstraints:^(MASConstraintMaker *make) {
  34. make.height.mas_equalTo(curWhiteBgHeight);
  35. make.width.mas_equalTo(300.f);
  36. make.centerY.mas_equalTo(-40.f);
  37. make.centerX.mas_equalTo(0.f);
  38. }];
  39. UIImageView *topImage = [[UIImageView alloc] init];
  40. topImage.image = [UIImage imageNamed:@"imageVersionFailTip"];
  41. [whiteBgView addSubview:topImage];
  42. [topImage mas_makeConstraints:^(MASConstraintMaker *make) {
  43. make.height.mas_equalTo(104.f);
  44. make.width.mas_equalTo(123.f);
  45. make.centerX.mas_equalTo(0.f);
  46. make.top.mas_equalTo(30.f);
  47. }];
  48. NSString *curTitleStr = NSLocalizedString(@"image_version_update_fail_title",nil);
  49. UILabel *titleLab = [[UILabel alloc] init];
  50. titleLab.text = curTitleStr;
  51. titleLab.numberOfLines = 0;
  52. titleLab.textColor = [UIColor blackColor];
  53. titleLab.font = [UIFont boldSystemFontOfSize:18.0];
  54. titleLab.textAlignment = NSTextAlignmentCenter;
  55. [whiteBgView addSubview:titleLab];
  56. [titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
  57. //make.height.mas_equalTo(60);
  58. make.right.mas_equalTo(-20.f);
  59. make.left.mas_equalTo(20.f);
  60. make.top.equalTo(topImage.mas_bottom).offset(20);
  61. }];
  62. NSString *tip1Str = NSLocalizedString(@"image_version_update_fail_tip1",nil);
  63. NSString *tip2Str = [[NSString alloc] initWithFormat:@"(%@)",ksharedAppDelegate.DeviceThirdIdMod.data.changeSn];
  64. NSString *tip3Str = NSLocalizedString(@"image_version_update_fail_tip2",nil);
  65. NSString*allTipStr = [[NSString alloc] initWithFormat:@"%@%@%@",tip1Str,tip2Str,tip3Str];
  66. UILabel *tipaLab = [[UILabel alloc] init];
  67. tipaLab.text = allTipStr;
  68. tipaLab.numberOfLines = 0;
  69. tipaLab.textColor = [UIColor hwColor:@"#666666"];
  70. tipaLab.font = [UIFont systemFontOfSize:14.0];
  71. //tipaLab.textAlignment = NSTextAlignmentCenter;
  72. [whiteBgView addSubview:tipaLab];
  73. [tipaLab mas_makeConstraints:^(MASConstraintMaker *make) {
  74. //make.height.mas_equalTo(60);
  75. make.right.mas_equalTo(-20.f);
  76. make.left.mas_equalTo(20.f);
  77. make.top.equalTo(titleLab.mas_bottom).offset(10);
  78. }];
  79. // NSString *tip2Str = [[NSString alloc] initWithFormat:@"SN:%@",ksharedAppDelegate.DeviceThirdIdMod.data.changeSn];
  80. // UILabel *tip2Lab = [[UILabel alloc] init];
  81. // tip2Lab.text = tip2Str;
  82. // tip2Lab.numberOfLines = 0;
  83. // tip2Lab.textColor = [UIColor hwColor:@"#666666"];
  84. // tip2Lab.font = [UIFont systemFontOfSize:14.0];
  85. // tip2Lab.textAlignment = NSTextAlignmentCenter;
  86. // [whiteBgView addSubview:tip2Lab];
  87. //
  88. // [tip2Lab mas_makeConstraints:^(MASConstraintMaker *make) {
  89. // //make.height.mas_equalTo(60);
  90. // make.right.mas_equalTo(-20.f);
  91. // make.left.mas_equalTo(20.f);
  92. // make.top.equalTo(tipaLab.mas_bottom).offset(5);
  93. // }];
  94. UIButton *knowBut = [[UIButton alloc] init];
  95. [knowBut setTitle:NSLocalizedString(@"common_I_know",nil) forState:UIControlStateNormal];
  96. //knowBut.layer.cornerRadius = 8;
  97. //knowBut.layer.masksToBounds = YES;
  98. [knowBut setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  99. [knowBut addTarget:self action:@selector(colseFun) forControlEvents:UIControlEventTouchUpInside];
  100. [whiteBgView addSubview:knowBut];
  101. CAGradientLayer *gradientLayer = [CAGradientLayer layer];
  102. gradientLayer.frame = CGRectMake(0, 0, 268, 40);
  103. gradientLayer.colors = @[(__bridge NSString *)[UIColor hwColor:@"#0CDEFD" alpha:1.0].CGColor, (__bridge NSString *)[UIColor hwColor:@"#058DFB" alpha:1.0].CGColor];
  104. gradientLayer.locations = @[@(0), @(1.0f)];
  105. gradientLayer.startPoint = CGPointMake(0, 0.5);
  106. gradientLayer.endPoint = CGPointMake(0.97, 0.5);
  107. gradientLayer.cornerRadius = 8;
  108. [knowBut.layer addSublayer:gradientLayer];
  109. // knowBut.layer.shadowColor = [UIColor hwColor:@"#058DFB"].CGColor;
  110. // // 设置阴影透明度(0.0到1.0)
  111. // knowBut.layer.shadowOpacity = 0.5;
  112. // // 设置阴影偏移量(x, y)
  113. // knowBut.layer.shadowOffset = CGSizeMake(0, 3);
  114. // // 设置阴影模糊半径
  115. // knowBut.layer.shadowRadius = 5.0;
  116. // // 为了使阴影在按钮外部可见,需要设置masksToBounds为NO
  117. // // 注意:如果父视图设置了masksToBounds为YES,那么阴影可能仍然不可见
  118. // knowBut.layer.masksToBounds = NO;
  119. [knowBut mas_makeConstraints:^(MASConstraintMaker *make) {
  120. make.height.mas_equalTo(40.f);
  121. make.width.mas_equalTo(268.f);
  122. make.centerX.mas_equalTo(0.f);
  123. make.bottom.mas_equalTo(-30);
  124. }];
  125. }
  126. - (void)colseFun
  127. {
  128. [self removeFromSuperview];
  129. if(_didClickUpdateDoneFun){
  130. _didClickUpdateDoneFun();
  131. }
  132. }
  133. @end