仿Uber寫的一個(gè)視頻背景登錄界面

在寫的時(shí)候,把問(wèn)題想復(fù)雜化了。后來(lái)發(fā)現(xiàn)系統(tǒng)自帶的

MediaPlayer/MediaPlayer.h

配合簡(jiǎn)單的動(dòng)畫就可以完成這個(gè)登錄界面。并沒(méi)有什么難度。

需要注意的是 視頻控制器的幾個(gè)屬性。



_moviePlayer.repeatMode=MPMovieRepeatModeOne;

_moviePlayer.shouldAutoplay=YES;

[_moviePlayersetFullscreen:YES];

[_moviePlayersetScalingMode:MPMovieScalingModeAspectFill];

[_moviePlayersetControlStyle:MPMovieControlStyleNone];


- (void)viewDidLoad {

[superviewDidLoad];

NSString* path = [[NSBundlemainBundle]pathForResource:@"mp4"ofType:@"mp4"];

_movieURL= [NSURLfileURLWithPath:path];

[selfreadyPlayer];

//創(chuàng)建view

UIView*newView=[[UIViewalloc]initWithFrame:CGRectMake(0,HEIGHT-84,WIDTH,64)];

newView.backgroundColor=[UIColorclearColor];

UIButton*loginBtn=[[UIButtonalloc]initWithFrame:CGRectMake(10,10, (WIDTH-20-30)/2,40)];

UIButton*regBtn=[[UIButtonalloc]initWithFrame:CGRectMake(10+30+(WIDTH-20-30)/2,10, (WIDTH-20-30)/2,40)];

loginBtn.backgroundColor=[UIColorwhiteColor];

[loginBtnsetTitleColor:[UIColorcolorWithRed:0.627green:0.631blue:0.651alpha:1.000]forState:UIControlStateNormal];

[loginBtnsetTitle:@"登錄"forState:UIControlStateNormal];

[loginBtn.layersetMasksToBounds:YES];

[loginBtn.layersetCornerRadius:5];//設(shè)置矩形四個(gè)圓角半徑

loginBtn.titleLabel.font= [UIFontsystemFontOfSize:15];

regBtn.backgroundColor=[UIColorcolorWithRed:0.247green:0.671blue:0.788alpha:1.000];

[regBtnsetTitleColor:[UIColorcolorWithRed:0.963green:0.972blue:1.000alpha:1.000]forState:UIControlStateNormal];

[regBtnsetTitle:@"注冊(cè)"forState:UIControlStateNormal];

regBtn.titleLabel.font= [UIFontsystemFontOfSize:15];

[regBtn.layersetMasksToBounds:YES];

[regBtn.layersetCornerRadius:5];//設(shè)置矩形四個(gè)圓角半徑

[newViewaddSubview:regBtn];

[newViewaddSubview:loginBtn];

[self.viewaddSubview:newView];

regBtn.alpha=0;

loginBtn.alpha=0;

[loginBtnaddTarget:selfaction:@selector(btnClick)forControlEvents:UIControlEventTouchDown];

[regBtnaddTarget:selfaction:@selector(btnClick)forControlEvents:UIControlEventTouchDown];

[UIViewanimateWithDuration:3animations:^{

regBtn.alpha=1;

loginBtn.alpha=1;

}completion:^(BOOLfinished) {

}];

}

-(void)btnClick

{

NSLog(@"登錄or注冊(cè)");

}

- (void) readyPlayer

{

[selfsetNeedsStatusBarAppearanceUpdate];

_moviePlayer= [[UBerBackgroundMoviealloc]initWithContentURL:_movieURL];

_moviePlayer.repeatMode=MPMovieRepeatModeOne;

_moviePlayer.shouldAutoplay=YES;

[_moviePlayersetFullscreen:YES];

[_moviePlayersetScalingMode:MPMovieScalingModeAspectFill];

[_moviePlayersetControlStyle:MPMovieControlStyleNone];

[[_moviePlayerview]setFrame:self.view.frame];

[[selfview]addSubview:[_moviePlayerview]];

[_moviePlayerplay];

}

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容