MPMoviePlayerViewController 应该像 YTPlayer 一样制作动画
MPMoviePlayerViewController should animate like YTPlayer
有什么简单的方法可以实现类似opening-closing的YTPlayer效果吗?我尝试了 Facebook 流行动画,但未能成功。这是我尝试过的一些代码:
UIView *fromView = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey].view;
fromView.tintAdjustmentMode = UIViewTintAdjustmentModeDimmed;
fromView.userInteractionEnabled = NO;
NSLog(@"Screen center: %f %ld",SCREEN_HEIGHT,(long)SCREEN_WIDTH);
NSLog(@"fromView center : %@", NSStringFromCGPoint(fromView.center));
UIView *toView = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey].view; CGRectGetWidth(transitionContext.containerView.bounds),
NSLog(@"Transition context center: %@", NSStringFromCGPoint(transitionContext.containerView.center));
//toView.center = CGPointMake(transitionContext.containerView.center.x, transitionContext.containerView.center.y);
toView.center = CGPointMake(0,0);
[transitionContext.containerView addSubview:toView];
NSLog(@"toView center : %@", NSStringFromCGPoint(toView.center));
POPSpringAnimation* scaleAnimationY = [POPSpringAnimation animationWithPropertyNamed:kPOPScrollViewZoomScale];
scaleAnimationY.fromValue = @(0);
scaleAnimationY.toValue=@(1);
POPSpringAnimation* scaleAnimationX = [POPSpringAnimation animationWithPropertyNamed:kPOPScrollViewZoomScale];
scaleAnimationX.fromValue = @(0);
scaleAnimationX.toValue=@(1);
POPSpringAnimation *positionAnimationY = [POPSpringAnimation animationWithPropertyNamed:kPOPLayerPositionY];
positionAnimationY.fromValue = @(self.view.frame.origin.y);
positionAnimationY.toValue = @(0);
positionAnimationY.springBounciness = 0;
[positionAnimationY setCompletionBlock:^(POPAnimation *anim, BOOL finished) {
[transitionContext completeTransition:YES];
}];
NSLog(@"positionAnimationY fromValue,toValue : %@ %@", positionAnimationY.fromValue, positionAnimationY.toValue);
POPSpringAnimation *positionAnimationX = [POPSpringAnimation animationWithPropertyNamed:kPOPLayerPositionX];
positionAnimationX.fromValue = @(self.view.frame.origin.x);
positionAnimationX.toValue = @(SCREEN_WIDTH);
positionAnimationX.springBounciness = 0;
[positionAnimationX setCompletionBlock:^(POPAnimation *anim, BOOL finished) {
//[transitionContext completeTransition:YES];
}];
NSLog(@"positionAnimationX fromValue, toValue : %@ %@", positionAnimationX.fromValue, positionAnimationX.toValue);
POPSpringAnimation *positionAnimation1Y = [POPSpringAnimation animationWithPropertyNamed:kPOPLayerPositionY];
positionAnimation1Y.fromValue = @(self.view.frame.origin.y);
positionAnimation1Y.toValue = @(SCREEN_HEIGHT);
positionAnimation1Y.springBounciness = 0;
[positionAnimation1Y setCompletionBlock:^(POPAnimation *anim, BOOL finished) {
[transitionContext completeTransition:YES];
}];
[toView.layer pop_addAnimation:scaleAnimationY forKey:@"scaleAnimationY"];
[toView.layer pop_addAnimation:scaleAnimationX forKey:@"scaleAnimationX"];
我说 YTPlayer 喜欢动画是什么意思:
1、打开效果:当点击视频时,视频应该逐渐覆盖整个屏幕。同时,背景也应该做同样的事情。
2. 关闭效果:点击完成后,视频应该逐渐消失并回到之前在 table 视图或 collection 视图中的位置。
谢谢:)
您可以安装在此处找到的 Pod 调用 YTPlayer:https://cocoapods.org/pods/youtube-ios-player-helper
或者您可以直接从这里获取文件:https://github.com/youtube/youtube-ios-player-helper
它没有很好的记录,但是您只需要传递 Youtube 视频 ID。这个包确实非常好地执行了 YouTube 效果。
有什么简单的方法可以实现类似opening-closing的YTPlayer效果吗?我尝试了 Facebook 流行动画,但未能成功。这是我尝试过的一些代码:
UIView *fromView = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey].view;
fromView.tintAdjustmentMode = UIViewTintAdjustmentModeDimmed;
fromView.userInteractionEnabled = NO;
NSLog(@"Screen center: %f %ld",SCREEN_HEIGHT,(long)SCREEN_WIDTH);
NSLog(@"fromView center : %@", NSStringFromCGPoint(fromView.center));
UIView *toView = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey].view; CGRectGetWidth(transitionContext.containerView.bounds),
NSLog(@"Transition context center: %@", NSStringFromCGPoint(transitionContext.containerView.center));
//toView.center = CGPointMake(transitionContext.containerView.center.x, transitionContext.containerView.center.y);
toView.center = CGPointMake(0,0);
[transitionContext.containerView addSubview:toView];
NSLog(@"toView center : %@", NSStringFromCGPoint(toView.center));
POPSpringAnimation* scaleAnimationY = [POPSpringAnimation animationWithPropertyNamed:kPOPScrollViewZoomScale];
scaleAnimationY.fromValue = @(0);
scaleAnimationY.toValue=@(1);
POPSpringAnimation* scaleAnimationX = [POPSpringAnimation animationWithPropertyNamed:kPOPScrollViewZoomScale];
scaleAnimationX.fromValue = @(0);
scaleAnimationX.toValue=@(1);
POPSpringAnimation *positionAnimationY = [POPSpringAnimation animationWithPropertyNamed:kPOPLayerPositionY];
positionAnimationY.fromValue = @(self.view.frame.origin.y);
positionAnimationY.toValue = @(0);
positionAnimationY.springBounciness = 0;
[positionAnimationY setCompletionBlock:^(POPAnimation *anim, BOOL finished) {
[transitionContext completeTransition:YES];
}];
NSLog(@"positionAnimationY fromValue,toValue : %@ %@", positionAnimationY.fromValue, positionAnimationY.toValue);
POPSpringAnimation *positionAnimationX = [POPSpringAnimation animationWithPropertyNamed:kPOPLayerPositionX];
positionAnimationX.fromValue = @(self.view.frame.origin.x);
positionAnimationX.toValue = @(SCREEN_WIDTH);
positionAnimationX.springBounciness = 0;
[positionAnimationX setCompletionBlock:^(POPAnimation *anim, BOOL finished) {
//[transitionContext completeTransition:YES];
}];
NSLog(@"positionAnimationX fromValue, toValue : %@ %@", positionAnimationX.fromValue, positionAnimationX.toValue);
POPSpringAnimation *positionAnimation1Y = [POPSpringAnimation animationWithPropertyNamed:kPOPLayerPositionY];
positionAnimation1Y.fromValue = @(self.view.frame.origin.y);
positionAnimation1Y.toValue = @(SCREEN_HEIGHT);
positionAnimation1Y.springBounciness = 0;
[positionAnimation1Y setCompletionBlock:^(POPAnimation *anim, BOOL finished) {
[transitionContext completeTransition:YES];
}];
[toView.layer pop_addAnimation:scaleAnimationY forKey:@"scaleAnimationY"];
[toView.layer pop_addAnimation:scaleAnimationX forKey:@"scaleAnimationX"];
我说 YTPlayer 喜欢动画是什么意思: 1、打开效果:当点击视频时,视频应该逐渐覆盖整个屏幕。同时,背景也应该做同样的事情。 2. 关闭效果:点击完成后,视频应该逐渐消失并回到之前在 table 视图或 collection 视图中的位置。
谢谢:)
您可以安装在此处找到的 Pod 调用 YTPlayer:https://cocoapods.org/pods/youtube-ios-player-helper
或者您可以直接从这里获取文件:https://github.com/youtube/youtube-ios-player-helper
它没有很好的记录,但是您只需要传递 Youtube 视频 ID。这个包确实非常好地执行了 YouTube 效果。