123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- //
- // WelcomeVC.m
- // LNManager
- //
- // Created by EchoShacolee on 2018/1/12.
- // Copyright © 2018年 lee. All rights reserved.
- //
- #import "WelcomeVC.h"
- #import "LoginVC.h"
- @interface WelcomeVC ()<UIScrollViewDelegate>
- {
- UIPageControl *pageControl;
- }
- @end
- @implementation WelcomeVC
- - (void)viewDidLoad {
- [super viewDidLoad];
- [self myInit];
- }
- -(void)myInit
- {
- NSArray* images = @[@"下载进入页2.png",@"下载进入页3.png"];//@"下载进入页1.png",带安卓属性
- UIScrollView *scroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, kSize.width, kSize.height)];
- /**跳到第5页,也会欢迎结束
- */
- [scroll setContentSize:CGSizeMake(kSize.width* images.count+1, 0)];
- [scroll setBounces:NO];
- [scroll setShowsHorizontalScrollIndicator:NO];
- scroll.delegate = self;
- scroll.pagingEnabled = YES;
- [self.view addSubview:scroll];
-
- pageControl = [[UIPageControl alloc]initWithFrame:CGRectMake(0, kSize.height-50, kSize.width, 20)];
- pageControl.userInteractionEnabled = NO;
- // pageControl.pageIndicatorTintColor = [UIColor blackColor];
- // pageControl.currentPageIndicatorTintColor = [UIColor whiteColor];
- pageControl.numberOfPages = scroll.contentSize.width/scroll.frame.size.width;
- [self.view addSubview:pageControl];
-
- UIImageView* iv;
- for (int i =0; i<images.count; i++) {
- iv = [[UIImageView alloc] initWithFrame:kFrame];
- iv.x = kSize.width*i;
- [scroll addSubview:iv];
- [iv setImage:[UIImage imageNamed:images[i]]];
- if (i==images.count-1) {
- UIButton *btn = [UIButton buttonWithType:UIButtonTypeSystem];
- btn.frame = CGRectMake(kSize.width/2-45, kSize.height-90, 100, 40);
- btn.layer.masksToBounds = YES;
- btn.layer.cornerRadius = 8;
- btn.layer.borderWidth = 1;
- btn.layer.borderColor = [UIColor whiteColor].CGColor;
- [btn setTitle:@"请登录" forState:UIControlStateNormal];
- [btn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
- btn.backgroundColor = [UIColor clearColor];
- [btn addTarget:self action:@selector(btnClick) forControlEvents:UIControlEventTouchUpInside];
- [iv addSubview:btn];
- iv.userInteractionEnabled = YES;
- }
- }
- }
- -(void)btnClick{
-
- LoginVC * loginvc = [[LoginVC alloc]init];
- KWINDOW.rootViewController = loginvc;
- }
- - (void)scrollViewDidScroll:(UIScrollView *)scrollView{
-
- CGPoint off = scrollView.contentOffset;
-
- if (off.x / kSize.width > 1) {
- LoginVC * loginvc = [[LoginVC alloc]init];
- KWINDOW.rootViewController = loginvc;
- }
-
- }
- - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
- pageControl.currentPage = scrollView.contentOffset.x/scrollView.frame.size.width;
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- /*
- #pragma mark - Navigation
- // In a storyboard-based application, you will often want to do a little preparation before navigation
- - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
- // Get the new view controller using [segue destinationViewController].
- // Pass the selected object to the new view controller.
- }
- */
- @end
|