KEEP引导页

作者: 西贝丶 | 来源:发表于2016-04-03 08:44 被阅读982次

    KEEP引导页


    简介:
    一个好的引导页会使得用户体验大大提升,那么视频引导页是一个不错的创新,页面分为视频,logo 轮播字, 以及注册登录两个按钮。


    界面预览:

    Keep.gif

    代码简单介绍:
    1.导入框架
    MediaPlayer.framework
    2.在Main.storyboard中进行视图的创建
    3.主要方法实现如下:

        -(void)playbackStateChanged{
    
    
    //取得目前状态
    MPMoviePlaybackState playbackState = [_moviePlayer playbackState];
    
    //状态类型
    switch (playbackState) {
        case MPMoviePlaybackStateStopped:
            [_moviePlayer play];
            break;
            
        case MPMoviePlaybackStatePlaying:
            NSLog(@"播放中");
            break;
            
        case MPMoviePlaybackStatePaused:
            [_moviePlayer play];
            break;
            
        case MPMoviePlaybackStateInterrupted:
            NSLog(@"播放被中断");
            break;
            
        case MPMoviePlaybackStateSeekingForward:
            NSLog(@"往前快转");
            break;
            
        case MPMoviePlaybackStateSeekingBackward:
            NSLog(@"往后快转");
            break;
            
        default:
            NSLog(@"无法辨识的状态");
            break;
    }
        }
    
    
    
    
        -(void)updateViewConstraints{
    
    [super updateViewConstraints];
    
    self.viewWidth.constant = CGRectGetWidth([UIScreen mainScreen].bounds) *4 ;
    self.secondViewLeading.constant = CGRectGetWidth([UIScreen mainScreen].bounds);
    
    self.thirdViewLeading.constant = CGRectGetWidth([UIScreen mainScreen].bounds) *2;
    self.fourViewLeading.constant =CGRectGetWidth([UIScreen mainScreen].bounds) *3;
    self.firstLabelWidth.constant = CGRectGetWidth([UIScreen mainScreen].bounds);
    
    self.secondLabelWidth.constant =CGRectGetWidth([UIScreen mainScreen].bounds);
    self.thridLabelWidth.constant = CGRectGetWidth([UIScreen mainScreen].bounds);
        }
    
    
    
        //ios以后隐藏状态栏
        -(BOOL)prefersStatusBarHidden{
    
    return YES;
        }- (UIStatusBarStyle)preferredStatusBarStyle
        {
    return UIStatusBarStyleLightContent;
        }
    
        -(void)setupTimer{
    
    self.timer = [NSTimer timerWithTimeInterval:3.0f target:self selector:@selector(timerChanged) userInfo:nil repeats:YES];
    
    [[NSRunLoop currentRunLoop]addTimer:self.timer forMode:NSRunLoopCommonModes];
    
        }
    
        -(void)pageChanged:(UIPageControl *)pageControl{
    
    CGFloat x = (pageControl.currentPage) * [UIScreen mainScreen].bounds.size.width;
    
    [self.scrollView setContentOffset:CGPointMake(x, 0) animated:YES];
    
    
        }
    
        -(void)timerChanged{
    int page  = (self.pageControl.currentPage +1) %4;
    
    self.pageControl.currentPage = page;
    
    [self pageChanged:self.pageControl];
    
    
        }- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{
    double page = self.scrollView.contentOffset.x / self.scrollView.bounds.size.width;
    self.pageControl.currentPage = page;
    
    if (page== - 1)
    {
        self.pageControl.currentPage = 3;// 序号0 最后1页
    }
    else if (page == 4)
    {
        self.pageControl.currentPage = 0; // 最后+1,循环第1页
        [self.scrollView setContentOffset:CGPointMake(0, 0) animated:YES];
    }
        }- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView{
    [self.timer invalidate];
        }- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate{
    
    [self setupTimer];
    
        }
    

    下载地址:
    http://pan.baidu.com/s/1c2fTe9q

    相关文章

      网友评论

      • angelancl:可以提供一下swift 2的源码吗?
      • 一洼世界:求新地址 蟹蟹
      • 名字难取Jay:您好,你给的去百度云下载demo的链接失效了,能否重新给个链接呀?

      本文标题:KEEP引导页

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