使用视频作为视图控制器的背景iOS
Use video as background of view controller iOS
有谁知道我如何使用背景视频作为登录,就像 AirBNB 之前的登录屏幕一样?我试过用gif,感觉分辨率不高
请告诉我!谢谢!
我自己还没有尝试过,但它至少应该能把你带到正确的方向:
- (void)viewDidLoad
{
[super viewDidLoad]
NSString *videoPath = [[NSBundle mainBundle] pathForResource:@"your_video_file_name" ofType:@"mp4"];
NSURL *videoURL = [NSURL fileURLWithPath:videoPath];
// or get your videoURL some another way
moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:videoURL];
[moviePlayer.view setFrame:self.view.bounds];
[self.view insertSubview:moviePlayer.view atIndex:0]; // to be sure it is a background
// [self.view addSubview:moviePlayer.view];
[moviePlayer prepareToPlay];
[moviePlayer play];
}
有谁知道我如何使用背景视频作为登录,就像 AirBNB 之前的登录屏幕一样?我试过用gif,感觉分辨率不高
请告诉我!谢谢!
我自己还没有尝试过,但它至少应该能把你带到正确的方向:
- (void)viewDidLoad
{
[super viewDidLoad]
NSString *videoPath = [[NSBundle mainBundle] pathForResource:@"your_video_file_name" ofType:@"mp4"];
NSURL *videoURL = [NSURL fileURLWithPath:videoPath];
// or get your videoURL some another way
moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:videoURL];
[moviePlayer.view setFrame:self.view.bounds];
[self.view insertSubview:moviePlayer.view atIndex:0]; // to be sure it is a background
// [self.view addSubview:moviePlayer.view];
[moviePlayer prepareToPlay];
[moviePlayer play];
}