Objective c 电影回放完成和过渡';s效应
我想知道如何添加过渡(视频开始时淡入,视频结束时淡出) 你能帮他完成这项任务吗?我有点迷茫于过渡期,以前从未玩过 这是我的密码Objective c 电影回放完成和过渡';s效应,objective-c,xcode,mpmovieplayercontroller,transition,effect,Objective C,Xcode,Mpmovieplayercontroller,Transition,Effect,我想知道如何添加过渡(视频开始时淡入,视频结束时淡出) 你能帮他完成这项任务吗?我有点迷茫于过渡期,以前从未玩过 这是我的密码 - (void) startSlideShow { NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"2" ofType:@"mov"]]; MPMoviePlay
- (void) startSlideShow
{
NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle]
pathForResource:@"2" ofType:@"mov"]];
MPMoviePlayerController *moviePlayer =
[[MPMoviePlayerController alloc] initWithContentURL:url];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlayBackDidFinish:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:moviePlayer];
moviePlayer.view.frame = CGRectMake(0, 0, 768, 1024);
moviePlayer.controlStyle = MPMovieControlStyleDefault;
moviePlayer.shouldAutoplay = YES;
[self.view addSubview:moviePlayer.view];
[moviePlayer setFullscreen:YES animated:YES];
}
-(void)moviePlayBackDidFinish: (NSNotification*)notification
{
MPMoviePlayerController *moviePlayer = [notification object];
[[NSNotificationCenter defaultCenter] removeObserver:self
name:MPMoviePlayerPlaybackDidFinishNotification
object:moviePlayer];
if ([moviePlayer respondsToSelector:@selector(setFullscreen:animated:)])
{
// the transition should be around here... (fade out)
[moviePlayer.view removeFromSuperview];
}
[moviePlayer release];
[self checkResources];
}
您可以在播放电影之前捕获UI的屏幕截图
UIGraphicsBeginImageContext(view.frame.size);
[view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *screenshotOfView = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
然后添加电影播放器,然后将图像添加为UIImageView(例如[[UIApplication sharedApplication]keyWindow])。然后将图像淡出
(我不知道您是否也可以从0-1为moviePlayer.view.alpha设置动画)
通过设置alpha值的动画,可以实现基本的淡入淡出/淡出:
view.alpha = 0.0;
[UIView animateWithDuration: 0.35 animations:^{
view.alpha = 1.0;
}];
我不明白。。。我想要的是在视频/图像开始时应用淡入/淡出效果。谢谢你帮我,伙计!通过设置alpha值的动画,可以实现基本的淡入淡出/淡出。我将编辑我的答案。