YOUPAILCUpdateVersionVC.m 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. //
  2. // YOUPAILCUpdateVersionVC.m
  3. // zhimi
  4. //
  5. // Created by Apple on 2019/11/5.
  6. // Copyright © 2019 caiPro. All rights reserved.
  7. //
  8. #import "YOUPAILCUpdateVersionVC.h"
  9. #import "UIViewController+TFPresent.h"
  10. @interface YOUPAILCUpdateVersionVC ()<UIGestureRecognizerDelegate,CAAnimationDelegate>
  11. @property(nonatomic,strong)UILabel *youpaipupdateTextLab,*youpaiptitleLab,*youpaipversionLab;
  12. @property(nonatomic,strong)UIButton *youpaipupdateBtn;
  13. @property(nonatomic,strong)UIButton *youpaipnoBtn;
  14. @property(nonatomic,strong)UIImageView *youpaipbackImageView;
  15. @end
  16. @implementation YOUPAILCUpdateVersionVC
  17. - (void)viewDidLoad {
  18. [super viewDidLoad];
  19. // [self.view setFrame:CGRectMake(0, 0, _screenWidth, _screenHeight)];
  20. // [self.view setBackgroundColor:[UIColor clearColor]];
  21. // CAShapeLayer *maskLayer = [CAShapeLayer layer];
  22. // UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:self.view.bounds cornerRadius:10];
  23. // maskLayer.path = path.CGPath;
  24. // self.view.layer.mask = maskLayer;
  25. UIView *whiteView = [[UIView alloc] init];
  26. [self.baseView addSubview:whiteView];
  27. whiteView.backgroundColor = LCWhiteColor;
  28. [whiteView mas_remakeConstraints:^(MASConstraintMaker *make) {
  29. make.left.equalTo(self.baseView.mas_left).with.offset(0);
  30. make.right.equalTo(self.baseView.mas_right).with.offset(0);
  31. make.top.equalTo(self.baseView.mas_top).with.offset(self.vWidth*31.5/305.0);
  32. make.bottom.equalTo(self.baseView.mas_bottom).with.offset(0);
  33. }];
  34. UIView *baseView = [[UIView alloc] init];
  35. [whiteView addSubview:baseView];
  36. baseView.backgroundColor = HexColorFromRGB(0xF8F8FF);
  37. baseView.layer.cornerRadius = 8;
  38. baseView.layer.masksToBounds = YES;
  39. [baseView mas_remakeConstraints:^(MASConstraintMaker *make) {
  40. make.left.equalTo(whiteView.mas_left).with.offset(31);
  41. make.right.equalTo(whiteView.mas_right).with.offset(-31);
  42. make.top.equalTo(whiteView.mas_top).with.offset(0);
  43. make.bottom.equalTo(whiteView.mas_bottom).with.offset(-31);
  44. }];
  45. [self.baseView addSubview:self.youpaipbackImageView];
  46. [_youpaipbackImageView setFrame:CGRectMake(0, 0, self.vWidth, self.vWidth*203/305.0)];
  47. [_youpaipbackImageView setImage:[UIImage imageNamed:@"vqu_images_P_version"]];
  48. [baseView addSubview:self.youpaiptitleLab];
  49. [_youpaiptitleLab setText:@"发现新版本"];
  50. [_youpaiptitleLab mas_remakeConstraints:^(MASConstraintMaker *make) {
  51. make.left.equalTo(baseView.mas_left).with.offset(0);
  52. make.right.equalTo(baseView.mas_right).with.offset(0);
  53. make.top.equalTo(baseView.mas_top).with.offset(self.vWidth*171.5/305.0+25);
  54. make.height.equalTo(@23);
  55. }];
  56. [baseView addSubview:self.youpaipversionLab];
  57. [_youpaipversionLab mas_remakeConstraints:^(MASConstraintMaker *make) {
  58. make.left.equalTo(baseView.mas_left).with.offset(27);
  59. make.right.equalTo(baseView.mas_right).with.offset(-10);
  60. make.top.equalTo(self->_youpaiptitleLab.mas_bottom).with.offset(14);
  61. make.height.equalTo(@17);
  62. }];
  63. [_youpaipversionLab setText:[NSString stringWithFormat:@"V %@",self.youpaipversionStr]];
  64. [baseView addSubview:self.youpaipupdateBtn];
  65. [_youpaipupdateBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
  66. make.left.equalTo(baseView.mas_left).with.offset(59);
  67. make.right.equalTo(baseView.mas_right).with.offset(-59);
  68. make.bottom.equalTo(baseView.mas_bottom).with.offset(-32);
  69. make.height.equalTo(@30);
  70. }];
  71. [baseView addSubview:self.youpaipnoBtn];
  72. [_youpaipnoBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
  73. make.left.equalTo(baseView.mas_left).with.offset(59);
  74. make.right.equalTo(baseView.mas_right).with.offset(-59);
  75. make.bottom.equalTo(baseView.mas_bottom).with.offset(-15);
  76. make.height.equalTo(@12);
  77. }];
  78. [baseView addSubview:self.youpaipupdateTextLab];
  79. [_youpaipupdateTextLab mas_remakeConstraints:^(MASConstraintMaker *make) {
  80. make.left.equalTo(baseView.mas_left).with.offset(27);
  81. make.right.equalTo(baseView.mas_right).with.offset(-27);
  82. make.bottom.equalTo(self->_youpaipupdateBtn.mas_top).with.offset(-27);
  83. make.top.equalTo(self->_youpaipversionLab.mas_bottom).with.offset(7);
  84. }];
  85. [_youpaipupdateTextLab setText:_youpaipupdateText];
  86. NSLog(@"%@",_youpaipupdateText);
  87. }
  88. -(UILabel*)youpaiptitleLab
  89. {
  90. if(!_youpaiptitleLab)
  91. {
  92. _youpaiptitleLab = [[UILabel alloc]init];
  93. [_youpaiptitleLab setTextColor:HexColorFromRGB(0x333333)];
  94. [_youpaiptitleLab setFont:LCBoldFont(19)];
  95. [_youpaiptitleLab setTextAlignment:NSTextAlignmentCenter];
  96. }
  97. return _youpaiptitleLab;
  98. }
  99. -(UILabel*)youpaipversionLab
  100. {
  101. if(!_youpaipversionLab)
  102. {
  103. _youpaipversionLab = [[UILabel alloc]init];
  104. [_youpaipversionLab setTextColor:HexColorFromRGB(0x626262)];
  105. [_youpaipversionLab setFont:LCFont(14)];
  106. }
  107. return _youpaipversionLab;
  108. }
  109. -(UILabel*)youpaipupdateTextLab
  110. {
  111. if(!_youpaipupdateTextLab)
  112. {
  113. _youpaipupdateTextLab = [[UILabel alloc]init];
  114. [_youpaipupdateTextLab setTextColor:HexColorFromRGB(0x626262)];
  115. _youpaipupdateTextLab.numberOfLines =0;
  116. _youpaipupdateTextLab.lineBreakMode = NSLineBreakByWordWrapping;
  117. [_youpaipupdateTextLab setFont:[UIFont systemFontOfSize:14]];
  118. [_youpaipupdateTextLab setTextAlignment:NSTextAlignmentLeft];
  119. }
  120. return _youpaipupdateTextLab;
  121. }
  122. -(UIButton *)youpaipupdateBtn
  123. {
  124. if(_youpaipupdateBtn==nil)
  125. {
  126. _youpaipupdateBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  127. // [_updateBtn setBackgroundImage:[LCTools ColorImage:CGSizeMake(KScreenWidth-120, 44) FromColors:@[LCGradientOneColor,LCGradientTwoColor] ByGradientType:(GradientLeftToRight)] forState:(UIControlStateNormal)];
  128. [_youpaipupdateBtn setBackgroundColor:HexColorFromRGB(0xA7A9FD)];
  129. [_youpaipupdateBtn setTitle:@"立即升级" forState:UIControlStateNormal];
  130. _youpaipupdateBtn.titleLabel.textColor = [UIColor whiteColor];
  131. _youpaipupdateBtn.titleLabel.textAlignment = NSTextAlignmentCenter;
  132. [_youpaipupdateBtn.titleLabel setFont:[UIFont systemFontOfSize:14]];
  133. _youpaipupdateBtn.layer.cornerRadius = 15;
  134. _youpaipupdateBtn.layer.masksToBounds = YES;
  135. [_youpaipupdateBtn addTarget:self action:@selector(youpaifupdateApp) forControlEvents:UIControlEventTouchUpInside];
  136. }
  137. return _youpaipupdateBtn;
  138. }
  139. -(UIButton *)youpaipnoBtn
  140. {
  141. if(_youpaipnoBtn==nil)
  142. {
  143. _youpaipnoBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  144. [_youpaipnoBtn setTitle:@"以后再说" forState:UIControlStateNormal];
  145. [_youpaipnoBtn setTitleColor:HexColorFromRGB(0x999999) forState:0];
  146. [_youpaipnoBtn.titleLabel setFont:[UIFont systemFontOfSize:10]];
  147. [_youpaipnoBtn addTarget:self action:@selector(youpaifnoBtnAction) forControlEvents:UIControlEventTouchUpInside];
  148. }
  149. return _youpaipnoBtn;
  150. }
  151. -(UIImageView*)youpaipbackImageView
  152. {
  153. if(!_youpaipbackImageView)
  154. {
  155. _youpaipbackImageView = [[UIImageView alloc]init];
  156. }
  157. return _youpaipbackImageView;
  158. }
  159. -(void)youpaifupdateApp
  160. {
  161. [[UIApplication sharedApplication] openURL:[NSURL URLWithString:self.youpaipdownLoadUrl]];
  162. if(self.youpaipenforce ==0)
  163. [self dismissViewControllerAnimated:YES completion:nil];
  164. // [[UIApplication sharedApplication] openURL:[NSURL URLWithString:self.downLoadUrl]];
  165. }
  166. -(void)youpaifshakeWindow
  167. {
  168. //shakeType 1 左右抖动 2左边抖动
  169. [self youpaiflayerRotation:self.view RepeatTime:1 shakeType:1];
  170. }
  171. - (void)youpaiflayerRotation:(UIView *)view RepeatTime:(NSInteger )repatTime shakeType:(NSInteger)shakeType{
  172. CAKeyframeAnimation *keyAnimation = [CAKeyframeAnimation animation];
  173. // 旋转角度, 其中的value表示图像旋转的最终位置
  174. if(shakeType == 1)
  175. {
  176. keyAnimation.values = [NSArray arrayWithObjects:
  177. [NSValue valueWithCATransform3D:CATransform3DMakeRotation(0, 0,1,0)],
  178. [NSValue valueWithCATransform3D:CATransform3DMakeRotation((M_PI/8), 0,1,0)],
  179. [NSValue valueWithCATransform3D:CATransform3DMakeRotation(0, 0,1,0)],
  180. [NSValue valueWithCATransform3D:CATransform3DMakeRotation(-(M_PI/8), 0,1,0)],
  181. [NSValue valueWithCATransform3D:CATransform3DMakeRotation(0, 0,1,0)],nil];
  182. }
  183. else
  184. {
  185. keyAnimation.values = [NSArray arrayWithObjects:
  186. [NSValue valueWithCATransform3D:CATransform3DMakeRotation(0, 0,1,0)],
  187. [NSValue valueWithCATransform3D:CATransform3DMakeRotation((M_PI/8), 0,1,0)],
  188. [NSValue valueWithCATransform3D:CATransform3DMakeRotation(0, 0,1,0)],nil];
  189. }
  190. keyAnimation.cumulative = NO;
  191. keyAnimation.duration = 0.6 * 1;
  192. keyAnimation.repeatCount = repatTime;
  193. keyAnimation.removedOnCompletion = NO;
  194. keyAnimation.delegate = self;
  195. [view.layer addAnimation:keyAnimation forKey:@"transform"];
  196. // [self performSelector:@selector(changeImg) withObject:nil afterDelay:0.6 * 1];
  197. }
  198. -(void)youpaifnoBtnAction
  199. {
  200. [self TFDismissViewController];
  201. }
  202. @end