NewStartViewContrller.m 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. //
  2. // NewStartViewContrller.m
  3. // MingMen
  4. //
  5. // Created by 罗云飞 on 2017/3/9.
  6. // Copyright © 2017年 罗云飞. All rights reserved.
  7. //
  8. #import "NewStartViewContrller.h"
  9. #import "StyledPageControl.h"
  10. #define GuidePageSize 3
  11. @interface NewStartViewContrller ()<UIScrollViewDelegate>{
  12. UIScrollView *myScrollView;
  13. StyledPageControl *myPageControl;
  14. }
  15. @end
  16. @implementation NewStartViewContrller
  17. - (void)viewDidLoad {
  18. [super viewDidLoad];
  19. // Do any additional setup after loading the view.
  20. [self.view setBackgroundColor:NewLineGrayColor];
  21. [self createSM_GuideViewWtihPageSize:GuidePageSize];
  22. }
  23. - (void) createSM_GuideViewWtihPageSize : (NSInteger) pageSize
  24. {
  25. myScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT)];
  26. [myScrollView setDelegate:self];
  27. [myScrollView setPagingEnabled:YES];
  28. [myScrollView setShowsHorizontalScrollIndicator:NO];
  29. [myScrollView setShowsVerticalScrollIndicator:NO];
  30. myScrollView.contentSize = CGSizeMake(SCREEN_WIDTH * pageSize, SCREEN_HEIGHT);
  31. [myScrollView setBackgroundColor:[UIColor clearColor]];
  32. [self.view addSubview:myScrollView];
  33. for (int i = 0; i < pageSize; i ++)
  34. {
  35. UITapGestureRecognizer *tapGes = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(showIndex:)];
  36. UIImageView *img_view = [[UIImageView alloc] initWithFrame:CGRectMake(SCREEN_WIDTH * i,0,SCREEN_WIDTH,SCREEN_HEIGHT)];
  37. [img_view setContentMode:UIViewContentModeScaleAspectFit];
  38. img_view.userInteractionEnabled = YES;
  39. if (i == pageSize-1) {
  40. [img_view addGestureRecognizer:tapGes];
  41. }
  42. [img_view setBackgroundColor:NewClearColor];
  43. NSString *imgName = @"";
  44. if (SCREEN_WIDTH == 320 && SCREEN_HEIGHT == 568) {
  45. imgName = NewStringFormat(@"Guide%d_5",i+1);
  46. }else if (SCREEN_WIDTH == 375 && SCREEN_HEIGHT == 667) {
  47. imgName = NewStringFormat(@"Guide%d_6",i+1);
  48. }else if (SCREEN_WIDTH == 414 && SCREEN_HEIGHT == 736) {
  49. imgName = NewStringFormat(@"Guide%d_6+",i+1);
  50. }else{
  51. imgName = NewStringFormat(@"Guide%d_5",i+1);
  52. [img_view setContentMode:UIViewContentModeScaleAspectFill];
  53. }
  54. [img_view setImage:[UIImage imageNamed:imgName]];
  55. [myScrollView addSubview:img_view];
  56. }
  57. }
  58. - (void) createSM_GuidePageCtrWihtPageNum : (int) _pageNum currentPage : (int) _currentPage
  59. {
  60. myPageControl = [[StyledPageControl alloc] initWithFrame:CGRectMake((SCREEN_WIDTH - 120.f)/2, SCREEN_HEIGHT-30.0f, 120.0f, 30.0f)];
  61. [myPageControl setBackgroundColor:[UIColor clearColor]];
  62. myPageControl.numberOfPages = _pageNum;
  63. myPageControl.currentPage = _currentPage;
  64. [myPageControl setUserInteractionEnabled:NO];
  65. [self.view addSubview:myPageControl];
  66. }
  67. - (void)showIndex:(UITapGestureRecognizer*)sender
  68. {
  69. NewLoginViewController *vc = [[NewLoginViewController alloc] init];
  70. UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:vc];
  71. [AppDelegate shareDelegate].window.rootViewController = navi;
  72. }
  73. - (void)didReceiveMemoryWarning {
  74. [super didReceiveMemoryWarning];
  75. // Dispose of any resources that can be recreated.
  76. }
  77. /*
  78. #pragma mark - Navigation
  79. // In a storyboard-based application, you will often want to do a little preparation before navigation
  80. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  81. // Get the new view controller using [segue destinationViewController].
  82. // Pass the selected object to the new view controller.
  83. }
  84. */
  85. @end