使用视频作为视图控制器iOS的背景

时间:2015-07-14 22:23:20

标签: ios objective-c video background

有谁知道如何使用背景视频作为登录,就像之前AirBNB的登录屏幕一样?我试图使用gif,但感觉它没有很好的分辨率。

请告诉我!谢谢!

1 个答案:

答案 0 :(得分:0)

我自己没有尝试过,但至少应该把你带到正确的方向:

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