引导页

作者: 哎呀我去i | 来源:发表于2017-10-26 10:13 被阅读0次

判断版本号

// 创始字符串
    NSString *path = [[NSBundle mainBundle] pathForResource:@"Info.plist" ofType:nil];
    // 创建字典
    NSDictionary *dic = [NSDictionary dictionaryWithContentsOfFile:path];
    // 打印版本的key
    NSLog(@"%@",[dic objectForKey:@"CFBundleVersion"]);
    
    
    // 判断
    if ([[dic objectForKey:@"CFBundleVersion"] isEqualToString:[[NSUserDefaults standardUserDefaults] valueForKey:@"version"]]) {
        
        // 版本号相同
        // 进入主页面
        self.window.rootViewController = [[UINavigationController alloc] initWithRootViewController:[[ViewController alloc] init]];
    }else{
        
        // 版本号不相同
        // 进入引导页
        [[NSUserDefaults standardUserDefaults] setObject:[dic objectForKey:@"CFBundleVersion"] forKey:@"version"];
        self.window.rootViewController = [[YinDaoYeViewController alloc] init];
        
        
    }

引导页界面

// 创建滚动视图
    _myScroll = [[UIScrollView alloc] initWithFrame:self.view.frame];
    _myScroll.delegate = self;
    [self.view addSubview:_myScroll];
    
    // 设置滚动范围
    _myScroll.contentSize = CGSizeMake(self.view.frame.size.width * 4, self.view.frame.size.height);
    // 取消弹簧效果
    _myScroll.bounces = NO;
    // 取消水平滚动条
    _myScroll.showsHorizontalScrollIndicator = NO;
    // 设置翻页滚动
    _myScroll.pagingEnabled = YES;
    
    // 图片数组
    _imgArr = @[@"1.jpg",@"2.jpg",@"3.jpg",@"4.jpg"];
    
    // for 循环
    for (int i = 0; i < _imgArr.count; i ++) {
        
        // 图片框
        UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(self.view.frame.size.width * i, 0, self.view.frame.size.width, self.view.frame.size.height)];
        imgView.image = [UIImage imageNamed:_imgArr[i]];
        [_myScroll addSubview:imgView];
        
        imgView.userInteractionEnabled = YES;
        
        // 在最后一张图片上加按钮
        if (i == _imgArr.count - 1) {
            
            UIButton *btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
            btn.frame = CGRectMake((self.view.frame.size.width - 100)/2, 600, 100, 30);
            [btn setTitle:@"立即体验" forState:UIControlStateNormal];
            [btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
            btn.titleLabel.font = [UIFont systemFontOfSize:18];
            [btn addTarget:self action:@selector(didClick) forControlEvents:UIControlEventTouchUpInside];
            [imgView addSubview:btn];
        }
    }
    
    // 创建分页控件
    _page = [[UIPageControl alloc] initWithFrame:CGRectMake((self.view.frame.size.width - 100)/2, 670, 100, 30)];
    // 分页控件的个数
    _page.numberOfPages = _imgArr.count;
    // 所有控件的颜色
    _page.pageIndicatorTintColor = [UIColor blackColor];
    // 当前控件的颜色
    _page.currentPageIndicatorTintColor = [UIColor redColor];
    // 将分页控件添加到视图上
    [self.view addSubview:_page];

点击方法


// 立即体验按钮
-(void)didClick
{
    [self presentViewController:[[ViewController alloc] init] animated:YES completion:nil];
}

-(void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    _page.currentPage = _myScroll.contentOffset.x/self.view.frame.size.width;
}
// 定时器
            NSTimer *time = [NSTimer scheduledTimerWithTimeInterval:3 repeats:YES block:^(NSTimer * _Nonnull timer) {
                
                CGFloat offsetX = _myScroll.contentOffset.x;
                // 视图的动画
                [UIView animateWithDuration:0.3 animations:^{
                    
                    if (offsetX == self.view.frame.size.width * 3) {
                        
                        _myScroll.contentOffset = CGPointMake(0, 0);
                    }else{
                        
                       _myScroll.contentOffset = CGPointMake(offsetX + self.view.frame.size.width, 0);
                    }
                }];
            }];
            
            [time fire];

相关文章

  • 引导页

    // // ViewController.m // 引导页_课堂练习 // // Created by 张羽婷 o...

  • 引导页

    引导页是用户第一次使用app时,引导用户使用的页面,这个界面通常加载到进入界面的上面。我这个引导页是一个View,...

  • 引导页

    AppDelegate.m #import "AppDelegate.h" #import "ViewContro...

  • 引导页

    判断版本号 引导页界面 点击方法

  • 引导页

    引导页 引导页是在程序第一次安装的时候呈现出来的画面. 新建一个.pch.用于做程序中的声明.声明这几个变量 在 ...

  • 引导页

    sharedPreferences = getSharedPreferences("ues", MODE_PRIV...

  • 引导页

    引导页设计 一般不会超过5页。作用:让用户了解产品价值和功能,引导用户更快进入使用环境。 按照功能分类: 1.功能...

  • 引导页

    第一种方法: 通过点击按键的方式进入应用### 该方法需要两个视图控制器,一个用来创建引导页的滚动视图,另一个创建...

  • 引导页

  • 引导页

    APP启动视屏 APP第一次启动播放视频欢迎 https://github.com/Zws-China/start...

网友评论

      本文标题:引导页

      本文链接:https://www.haomeiwen.com/subject/ttmhpxtx.html