KEEP引導(dǎo)頁(yè)
簡(jiǎn)介:
一個(gè)好的引導(dǎo)頁(yè)會(huì)使得用戶體驗(yàn)大大提升理澎,那么視頻引導(dǎo)頁(yè)是一個(gè)不錯(cuò)的創(chuàng)新琳骡,頁(yè)面分為視頻,logo 輪播字祈纯, 以及注冊(cè)登錄兩個(gè)按鈕令宿。
界面預(yù)覽:
代碼簡(jiǎn)單介紹:
1.導(dǎo)入框架
MediaPlayer.framework
2.在Main.storyboard中進(jìn)行視圖的創(chuàng)建
3.主要方法實(shí)現(xiàn)如下:
-(void)playbackStateChanged{
//取得目前狀態(tài)
MPMoviePlaybackState playbackState = [_moviePlayer playbackState];
//狀態(tài)類型
switch (playbackState) {
case MPMoviePlaybackStateStopped:
[_moviePlayer play];
break;
case MPMoviePlaybackStatePlaying:
NSLog(@"播放中");
break;
case MPMoviePlaybackStatePaused:
[_moviePlayer play];
break;
case MPMoviePlaybackStateInterrupted:
NSLog(@"播放被中斷");
break;
case MPMoviePlaybackStateSeekingForward:
NSLog(@"往前快轉(zhuǎn)");
break;
case MPMoviePlaybackStateSeekingBackward:
NSLog(@"往后快轉(zhuǎn)");
break;
default:
NSLog(@"無(wú)法辨識(shí)的狀態(tài)");
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以后隱藏狀態(tài)欄
-(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;// 序號(hào)0 最后1頁(yè)
}
else if (page == 4)
{
self.pageControl.currentPage = 0; // 最后+1,循環(huán)第1頁(yè)
[self.scrollView setContentOffset:CGPointMake(0, 0) animated:YES];
}
}- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView{
[self.timer invalidate];
}- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate{
[self setupTimer];
}