GuideViewController.m 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. //
  2. // GuideViewController.m
  3. // 双子星云手机
  4. //
  5. // Created by APPLE on 2023/8/11.
  6. //
  7. #import "GuideViewController.h"
  8. #import "Masonry.h"
  9. #import "UIView+View.h"
  10. #import "GuideView.h"
  11. #import "GuideLastView.h"
  12. #import "SetPWDFirstViewController.h"
  13. #import "connectDeviceManager.h"
  14. @interface GuideViewController ()
  15. {
  16. UIScrollView *bgScrView;
  17. GuideView *guideView0;
  18. GuideView *guideView1;
  19. GuideView *guideView2;
  20. GuideView *guideView3;
  21. GuideLastView *guideLastView;
  22. }
  23. @end
  24. @implementation GuideViewController
  25. @synthesize delegate;
  26. @synthesize sn;
  27. - (void)viewDidLoad {
  28. [super viewDidLoad];
  29. // Do any additional setup after loading the view.
  30. [self drawAnyView];
  31. if([[connectDeviceManager shareInstance] curConnectDeviceState] == DeviceConnectUnknown){
  32. [[connectDeviceManager shareInstance] getThridMsgBySN:sn];
  33. }
  34. }
  35. - (void)viewDidAppear:(BOOL)animated{
  36. [super viewDidAppear:animated];
  37. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(4 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  38. [self startMoveView];
  39. });
  40. }
  41. - (void)startMoveView{
  42. CGFloat x = bgScrView.contentOffset.x;
  43. NSInteger index = (x+1)/self.view.width;
  44. if (index == 4){
  45. /*记录已经用户引导*/
  46. [HWDataManager setBoolWithKey:Const_Have_Show_Guide value:YES];
  47. /*设置密码*/
  48. SetPWDFirstViewController *nextVC = [[SetPWDFirstViewController alloc] init];
  49. [self.navigationController pushViewController:nextVC animated:YES];
  50. }else{
  51. [bgScrView setContentOffset:CGPointMake((index + 1)*self.view.width, 0) animated:YES];
  52. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(4 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  53. [self startMoveView];
  54. });
  55. }
  56. }
  57. - (void)drawAnyView{
  58. [self.view setBackgroundColor:HWF5F7FAColor];
  59. bgScrView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.width, self.view.height)];
  60. [bgScrView setBackgroundColor:HWF5F7FAColor];
  61. [bgScrView setShowsVerticalScrollIndicator:NO];
  62. [bgScrView setShowsHorizontalScrollIndicator:NO];
  63. [bgScrView setPagingEnabled:YES];
  64. [bgScrView setUserInteractionEnabled:NO];
  65. [bgScrView setContentSize:CGSizeMake(5*self.view.width,self.view.height)];
  66. [bgScrView setClipsToBounds:YES];
  67. [self.view addSubview:bgScrView];
  68. guideView0 = [[GuideView alloc] initWithTips:NSLocalizedString(@"guide_middle_tips_0",nil)
  69. imageName:@"guide_middle_0_icon"
  70. index:0];
  71. guideView1 = [[GuideView alloc] initWithTips:NSLocalizedString(@"guide_middle_tips_1",nil)
  72. imageName:@"guide_middle_1_icon"
  73. index:1];
  74. guideView2 = [[GuideView alloc] initWithTips:NSLocalizedString(@"guide_middle_tips_2",nil)
  75. imageName:@"guide_middle_2_icon"
  76. index:2];
  77. guideView3 = [[GuideView alloc] initWithTips:NSLocalizedString(@"guide_middle_tips_3",nil)
  78. imageName:@"guide_middle_3_icon"
  79. index:3];
  80. guideView0.frame = CGRectMake(0*self.view.width, 0, self.view.width,self.view.height);
  81. guideView1.frame = CGRectMake(1*self.view.width, 0, self.view.width,self.view.height);
  82. guideView2.frame = CGRectMake(2*self.view.width, 0, self.view.width,self.view.height);
  83. guideView3.frame = CGRectMake(3*self.view.width, 0, self.view.width,self.view.height);
  84. [bgScrView addSubview:guideView0];
  85. [bgScrView addSubview:guideView1];
  86. [bgScrView addSubview:guideView2];
  87. [bgScrView addSubview:guideView3];
  88. guideLastView = [[GuideLastView alloc] initWithFrame:CGRectMake(4*self.view.width, 0, self.view.width,self.view.height)];
  89. [bgScrView addSubview:guideLastView];
  90. }
  91. @end