KEEP引导页

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

你可能感兴趣的:(KEEP引导页)