仿Uber写的一个视频背景登录界面

在写的时候,把问题想复杂化了。后来发现系统自带的

MediaPlayer/MediaPlayer.h

配合简单的动画就可以完成这个登录界面。并没有什么难度。

需要注意的是 视频控制器的几个属性。



_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];

//创建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];//设置矩形四个圆角半径

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:@"注册"forState:UIControlStateNormal];

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

[regBtn.layersetMasksToBounds:YES];

[regBtn.layersetCornerRadius:5];//设置矩形四个圆角半径

[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注册");

}

- (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];

}

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容