我制作 iOS 应用程序。
我使用 MPMoviePlayerController,但这显示黑色背景。
我认为这个问题可以通过这个URL解决,但我不明白使用方式。
MPMoviePlayerController 背景颜色不会粘住 https://stackoverflow.com/questions/7974349/mpmovieplayercontroller-background-color-wont-stick
我的代码是这样的。
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
请告知清楚的背景方式。
您需要将其更改为:
moviePlayer.backgroundView.backgroundColor = [UIColor clearColor];
for(UIView *aSubView in moviePlayer.view.subviews) {
aSubView.backgroundColor = [UIColor clearColor];
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)