WelcomeVC.m 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. //
  2. // WelcomeVC.m
  3. // LNManager
  4. //
  5. // Created by EchoShacolee on 2018/1/12.
  6. // Copyright © 2018年 lee. All rights reserved.
  7. //
  8. #import "WelcomeVC.h"
  9. #import "LoginVC.h"
  10. @interface WelcomeVC ()<UIScrollViewDelegate>
  11. {
  12. UIPageControl *pageControl;
  13. }
  14. @end
  15. @implementation WelcomeVC
  16. - (void)viewDidLoad {
  17. [super viewDidLoad];
  18. [self myInit];
  19. }
  20. -(void)myInit
  21. {
  22. NSArray* images = @[@"下载进入页2.png",@"下载进入页3.png"];//@"下载进入页1.png",带安卓属性
  23. UIScrollView *scroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, kSize.width, kSize.height)];
  24. /**跳到第5页,也会欢迎结束
  25. */
  26. [scroll setContentSize:CGSizeMake(kSize.width* images.count+1, 0)];
  27. [scroll setBounces:NO];
  28. [scroll setShowsHorizontalScrollIndicator:NO];
  29. scroll.delegate = self;
  30. scroll.pagingEnabled = YES;
  31. [self.view addSubview:scroll];
  32. pageControl = [[UIPageControl alloc]initWithFrame:CGRectMake(0, kSize.height-50, kSize.width, 20)];
  33. pageControl.userInteractionEnabled = NO;
  34. // pageControl.pageIndicatorTintColor = [UIColor blackColor];
  35. // pageControl.currentPageIndicatorTintColor = [UIColor whiteColor];
  36. pageControl.numberOfPages = scroll.contentSize.width/scroll.frame.size.width;
  37. [self.view addSubview:pageControl];
  38. UIImageView* iv;
  39. for (int i =0; i<images.count; i++) {
  40. iv = [[UIImageView alloc] initWithFrame:kFrame];
  41. iv.x = kSize.width*i;
  42. [scroll addSubview:iv];
  43. [iv setImage:[UIImage imageNamed:images[i]]];
  44. if (i==images.count-1) {
  45. UIButton *btn = [UIButton buttonWithType:UIButtonTypeSystem];
  46. btn.frame = CGRectMake(kSize.width/2-45, kSize.height-90, 100, 40);
  47. btn.layer.masksToBounds = YES;
  48. btn.layer.cornerRadius = 8;
  49. btn.layer.borderWidth = 1;
  50. btn.layer.borderColor = [UIColor whiteColor].CGColor;
  51. [btn setTitle:@"请登录" forState:UIControlStateNormal];
  52. [btn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  53. btn.backgroundColor = [UIColor clearColor];
  54. [btn addTarget:self action:@selector(btnClick) forControlEvents:UIControlEventTouchUpInside];
  55. [iv addSubview:btn];
  56. iv.userInteractionEnabled = YES;
  57. }
  58. }
  59. }
  60. -(void)btnClick{
  61. LoginVC * loginvc = [[LoginVC alloc]init];
  62. KWINDOW.rootViewController = loginvc;
  63. }
  64. - (void)scrollViewDidScroll:(UIScrollView *)scrollView{
  65. CGPoint off = scrollView.contentOffset;
  66. if (off.x / kSize.width > 1) {
  67. LoginVC * loginvc = [[LoginVC alloc]init];
  68. KWINDOW.rootViewController = loginvc;
  69. }
  70. }
  71. - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
  72. pageControl.currentPage = scrollView.contentOffset.x/scrollView.frame.size.width;
  73. }
  74. - (void)didReceiveMemoryWarning {
  75. [super didReceiveMemoryWarning];
  76. // Dispose of any resources that can be recreated.
  77. }
  78. /*
  79. #pragma mark - Navigation
  80. // In a storyboard-based application, you will often want to do a little preparation before navigation
  81. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  82. // Get the new view controller using [segue destinationViewController].
  83. // Pass the selected object to the new view controller.
  84. }
  85. */
  86. @end