GuideViewController.m 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. //
  2. // GuideViewController.m
  3. // 双子星云手机
  4. //
  5. // Created by APPLE on 2023/8/11.
  6. //
  7. #import "GuideViewController.h"
  8. #import "Masonry.h"
  9. @interface GuideViewController ()
  10. {
  11. UIView *firstView;
  12. UIView *secondView;
  13. BOOL haveSure;
  14. UIButton *firstFlagBtn;
  15. UIButton *secondFlagBtn;
  16. }
  17. @end
  18. @implementation GuideViewController
  19. @synthesize delegate;
  20. - (void)viewDidLoad {
  21. [super viewDidLoad];
  22. haveSure = NO;
  23. // Do any additional setup after loading the view.
  24. [self drawAnyView];
  25. }
  26. - (void)drawAnyView{
  27. [self.view setBackgroundColor:HWF5F7FAColor];
  28. firstView = [[UIView alloc] initWithFrame:(CGRectMake(0, 0, SCREEN_W, SCREEN_H))];
  29. firstView.backgroundColor = HWF5F7FAColor;
  30. [self.view addSubview:firstView];
  31. UIImageView *firstImg = [[UIImageView alloc] init];
  32. [firstImg setBackgroundColor:[UIColor clearColor]];
  33. [firstImg setImage:[UIImage imageNamed:@"yindao1"]];
  34. [firstView addSubview:firstImg];
  35. [firstImg mas_makeConstraints:^(MASConstraintMaker *make) {
  36. make.left.mas_equalTo(0);
  37. make.right.mas_equalTo(0);
  38. make.top.mas_equalTo(0);
  39. make.height.mas_equalTo((SCREEN_W/375.f)*496.f);
  40. }];
  41. /*第一段文字*/
  42. UILabel *firstUpLabel = [[UILabel alloc] init];
  43. [firstUpLabel setBackgroundColor:[UIColor clearColor]];
  44. [firstUpLabel setTextColor:HW333333Color];
  45. [firstUpLabel setFont:[UIFont boldSystemFontOfSize:18]];
  46. [firstUpLabel setText:@"担心你的隐私被窥探?"];
  47. [firstUpLabel setTextAlignment:(NSTextAlignmentCenter)];
  48. [firstView addSubview:firstUpLabel];
  49. [firstUpLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  50. make.left.mas_equalTo(0);
  51. make.right.mas_equalTo(0);
  52. make.top.equalTo(firstImg.mas_bottom).offset(-12.5);
  53. make.height.mas_equalTo(25);
  54. }];
  55. /*第二段文字*/
  56. UILabel *firstdownLabel = [[UILabel alloc] init];
  57. [firstdownLabel setBackgroundColor:[UIColor clearColor]];
  58. [firstdownLabel setTextColor:HW666666Color];
  59. [firstdownLabel setFont:[UIFont systemFontOfSize:14]];
  60. [firstdownLabel setNumberOfLines:0];
  61. [firstdownLabel setText:@"你的另一台隐私手机,保证隐私,你的秘密\n只有你知道"];
  62. [firstdownLabel setTextAlignment:(NSTextAlignmentCenter)];
  63. [firstView addSubview:firstdownLabel];
  64. [firstdownLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  65. make.left.mas_equalTo(0);
  66. make.right.mas_equalTo(0);
  67. make.top.equalTo(firstUpLabel.mas_bottom).offset(1.5);
  68. make.height.mas_equalTo(54);
  69. }];
  70. secondView = [[UIView alloc] initWithFrame:(CGRectMake(SCREEN_W, 0, SCREEN_W, SCREEN_H))];
  71. secondView.backgroundColor = HWF5F7FAColor;
  72. [self.view addSubview:secondView];
  73. UIImageView *secondImg = [[UIImageView alloc] init];
  74. [secondImg setBackgroundColor:[UIColor clearColor]];
  75. [secondImg setImage:[UIImage imageNamed:@"yindao2"]];
  76. [secondView addSubview:secondImg];
  77. [secondImg mas_makeConstraints:^(MASConstraintMaker *make) {
  78. make.left.mas_equalTo(0);
  79. make.right.mas_equalTo(0);
  80. make.top.mas_equalTo(0);
  81. make.height.mas_equalTo((SCREEN_W/375.f)*496.f);
  82. }];
  83. /*第一段文字*/
  84. UILabel *secondUpLabel = [[UILabel alloc] init];
  85. [secondUpLabel setBackgroundColor:[UIColor clearColor]];
  86. [secondUpLabel setTextColor:HW333333Color];
  87. [secondUpLabel setFont:[UIFont boldSystemFontOfSize:18]];
  88. [secondUpLabel setText:@"想要更私密的聊天环境?"];
  89. [secondUpLabel setTextAlignment:(NSTextAlignmentCenter)];
  90. [secondView addSubview:secondUpLabel];
  91. [secondUpLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  92. make.left.mas_equalTo(0);
  93. make.right.mas_equalTo(0);
  94. make.top.equalTo(secondImg.mas_bottom).offset(-12.5);
  95. make.height.mas_equalTo(25);
  96. }];
  97. /*第二段文字*/
  98. UILabel *seconddownLabel = [[UILabel alloc] init];
  99. [seconddownLabel setBackgroundColor:[UIColor clearColor]];
  100. [seconddownLabel setTextColor:HW666666Color];
  101. [seconddownLabel setFont:[UIFont systemFontOfSize:14]];
  102. [seconddownLabel setNumberOfLines:0];
  103. [seconddownLabel setText:@"信息端对端加密防止泄露,让你的聊天内容\n更加私密"];
  104. [seconddownLabel setTextAlignment:(NSTextAlignmentCenter)];
  105. [secondView addSubview:seconddownLabel];
  106. [seconddownLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  107. make.left.mas_equalTo(0);
  108. make.right.mas_equalTo(0);
  109. make.top.equalTo(secondUpLabel.mas_bottom).offset(1.5);
  110. make.height.mas_equalTo(54);
  111. }];
  112. /*两个标签按钮*/
  113. firstFlagBtn = [[UIButton alloc] init];
  114. [firstFlagBtn setBackgroundColor:HWE3E8F1Color];
  115. firstFlagBtn.layer.cornerRadius = 5.f;
  116. [self.view addSubview:firstFlagBtn];
  117. [firstFlagBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  118. make.width.mas_equalTo(10);
  119. make.height.mas_equalTo(10);
  120. make.top.equalTo(firstImg.mas_bottom).offset(87.f);
  121. make.centerX.equalTo(self.view.mas_centerX).offset(-10 - 5.f);
  122. }];
  123. secondFlagBtn = [[UIButton alloc] init];
  124. [secondFlagBtn setBackgroundColor:HW13B2EBColor];
  125. secondFlagBtn.layer.cornerRadius = 5.f;
  126. [self.view addSubview:secondFlagBtn];
  127. [secondFlagBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  128. make.width.mas_equalTo(10);
  129. make.height.mas_equalTo(10);
  130. make.top.equalTo(firstImg.mas_bottom).offset(87.f);
  131. make.centerX.equalTo(self.view.mas_centerX).offset(+10 + 5.f);
  132. }];
  133. /*开始体验*/
  134. UIButton *startUseBtn = [[UIButton alloc] init];
  135. startUseBtn.frame = CGRectMake(0, 0, 160.f, 48.f);
  136. // gradient
  137. CAGradientLayer *gl = [CAGradientLayer layer];
  138. gl.frame = CGRectMake(0,0,160.f,48.f);
  139. gl.startPoint = CGPointMake(0, 0.5);
  140. gl.endPoint = CGPointMake(1, 0.5);
  141. gl.colors = @[(__bridge id)HW0CDEFDColor.CGColor, (__bridge id)HW058DFBColor.CGColor];
  142. gl.locations = @[@(0), @(1.0f)];
  143. [startUseBtn.layer addSublayer:gl];
  144. [startUseBtn addTarget:self action:@selector(startUseBtnPressed) forControlEvents:(UIControlEventTouchUpInside)];
  145. [startUseBtn setTitle:@"开始体验" forState:(UIControlStateNormal)];
  146. [startUseBtn setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)];
  147. [startUseBtn.titleLabel setFont:[UIFont systemFontOfSize:16.f]];
  148. [startUseBtn.layer setCornerRadius:8.f];
  149. startUseBtn.clipsToBounds = YES;
  150. [self.view addSubview:startUseBtn];
  151. [startUseBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  152. make.centerX.equalTo(self.view.mas_centerX);
  153. make.width.mas_equalTo(160.f);
  154. make.top.equalTo(secondFlagBtn.mas_bottom).offset(21.f);
  155. make.height.mas_equalTo(48.f);
  156. }];
  157. }
  158. - (void)startUseBtnPressed{
  159. /*记录已经用户引导*/
  160. [HWDataManager setBoolWithKey:Const_Have_Show_Guide value:YES];
  161. if ([delegate respondsToSelector:@selector(startUseBtnBePressed)]){
  162. [delegate startUseBtnBePressed];
  163. }
  164. }
  165. - (void)viewDidAppear:(BOOL)animated{
  166. [super viewDidAppear:animated];
  167. [self startAnim];
  168. }
  169. - (void)startAnim{
  170. if (haveSure){
  171. return;
  172. }
  173. [UIView animateWithDuration:1.2 animations:^{
  174. if (self->firstView.frame.origin.x == 0){
  175. self->firstView.frame = CGRectMake(-SCREEN_W, 0, SCREEN_W, SCREEN_H);
  176. self->secondView.frame = CGRectMake(0, 0, SCREEN_W, SCREEN_H);
  177. }else{
  178. self->firstView.frame = CGRectMake(0, 0, SCREEN_W, SCREEN_H);
  179. self->secondView.frame = CGRectMake(-SCREEN_W, 0, SCREEN_W, SCREEN_H);
  180. }
  181. } completion:^(BOOL finished) {
  182. if (self->firstView.frame.origin.x == 0){
  183. self->secondView.frame = CGRectMake(SCREEN_W, 0, SCREEN_W, SCREEN_H);
  184. [self->firstFlagBtn setBackgroundColor:HW13B2EBColor];
  185. [self->secondFlagBtn setBackgroundColor:HWE3E8F1Color];
  186. }else{
  187. self->firstView.frame = CGRectMake(SCREEN_W, 0, SCREEN_W, SCREEN_H);
  188. [self->firstFlagBtn setBackgroundColor:HWE3E8F1Color];
  189. [self->secondFlagBtn setBackgroundColor:HW13B2EBColor];
  190. }
  191. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  192. [self startAnim];
  193. });
  194. }];
  195. }
  196. /*
  197. #pragma mark - Navigation
  198. // In a storyboard-based application, you will often want to do a little preparation before navigation
  199. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  200. // Get the new view controller using [segue destinationViewController].
  201. // Pass the selected object to the new view controller.
  202. }
  203. */
  204. @end