我製作iOS應用程序。
我使用MPMoviePlayerController,但顯示黑色背景。
我覺得這個問題可以通過這個URL解決,但是我不明白使用方法。
MPMoviePlayerController background color won't stick
我的代碼是這樣的。MPMoviePlayerController存在黑色背景
NSString *path = [[NSBundle mainBundle] pathForResource:@"movie_files" ofType:@"m4v"];
NSURL *videoURL = [NSURL fileURLWithPath:path];
moviePlayer = [[MPMoviePlayerController alloc]
initWithContentURL:videoURL];
//setting
moviePlayer.scalingMode =MPMovieScalingModeAspectFit;
moviePlayer.controlStyle=MPMovieControlStyleDefault;
moviePlayer.shouldAutoplay=NO;
[moviePlayer.view setFrame:CGRectMake(20, 20, 280, 200)];
//notification
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlayBackDidFinish:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:moviePlayer];
//clearColor
UIView *subV =[[UIView alloc]init];
for(subV in moviePlayer.backgroundView.subviews) {
subV.backgroundColor = [UIColor clearColor];
}
[moviePlayer.view addSubview:subV];
[self.view addSubview:moviePlayer.view];
//show white screen
請告訴清楚背景的方式。
當使用'[UIColor redColor]'時會發生什麼,它會改變顏色嗎?在這種情況下,我認爲'clearColor'不起作用。 – skram