BoxHeartbeatReStartView~.m 5.5 KB

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