Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xcode/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 电影回放完成和过渡';s效应_Objective C_Xcode_Mpmovieplayercontroller_Transition_Effect - Fatal编程技术网

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值的动画,可以实现基本的淡入淡出/淡出。我将编辑我的答案。