Skip to content

Commit

Permalink
播放视图滑动隐藏优化
Browse files Browse the repository at this point in the history
  • Loading branch information
QuintGao committed Sep 12, 2019
1 parent b3c044a commit f2f083b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions GKDYVideo/Classes/Home/View/GKDYScaleVideoView.m
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ - (void)handlePanGesture:(UIPanGestureRecognizer *)panGesture {
CGFloat progress = translation.x / [UIScreen mainScreen].bounds.size.width;
progress = fminf(fmaxf(progress, 0.0f), 1.0f);
if (progress < 0.2) { // 恢复
self.vc.gk_statusBarHidden = YES;
self.vc.gk_interactivePopDisabled = YES;

[UIView animateWithDuration:0.25
delay:0
options:UIViewAnimationOptionCurveEaseOut
Expand All @@ -94,8 +97,6 @@ - (void)handlePanGesture:(UIPanGestureRecognizer *)panGesture {
self.videoView.transform = CGAffineTransformMakeScale(1.0f, 1.0f);
} completion:^(BOOL finished) {
self.interacting = NO;
self.vc.gk_statusBarHidden = YES;
self.vc.gk_interactivePopDisabled = YES;

[self.videoView resume];
self.backgroundColor = [UIColor blackColor];
Expand All @@ -112,6 +113,11 @@ - (void)handlePanGesture:(UIPanGestureRecognizer *)panGesture {
}

- (void)show {
// 隐藏状态栏及禁用手势
self.vc.gk_statusBarHidden = YES;
self.vc.gk_interactivePopDisabled = YES;

// 添加视图
[self.vc.view addSubview:self];

// 获取当前显示的列表控制器
Expand All @@ -128,18 +134,16 @@ - (void)show {
self.center = CGPointMake(originalFrame.origin.x + originalFrame.size.width * 0.5, originalFrame.origin.y + originalFrame.size.height * 0.5);
self.transform = CGAffineTransformMakeScale(originalFrame.size.width / finalFrame.size.width, originalFrame.size.height / finalFrame.size.height);

[UIView animateWithDuration:0.25
// 显示动画
[UIView animateWithDuration:0.3
delay:0
usingSpringWithDamping:0.8
initialSpringVelocity:1
options:UIViewAnimationOptionLayoutSubviews
animations:^{
self.center = CGPointMake(finalFrame.origin.x + finalFrame.size.width * 0.5, finalFrame.origin.y + finalFrame.size.height * 0.5);
self.transform = CGAffineTransformMakeScale(1, 1);
} completion:^(BOOL finished) {
self.vc.gk_statusBarHidden = YES;
self.vc.gk_interactivePopDisabled = YES;
}];
} completion:nil];
}

- (void)dismiss {
Expand Down Expand Up @@ -167,6 +171,7 @@ - (void)dismiss {
[self.videoView pause];
self.backgroundColor = [UIColor clearColor];

// 隐藏动画
[UIView animateWithDuration:0.25 delay:0 usingSpringWithDamping:0.8 initialSpringVelocity:0.2 options:UIViewAnimationOptionCurveEaseInOut animations:^{
snapShotView.frame = finalFrame;
} completion:^(BOOL finished) {
Expand Down
Binary file added imgs/dy_05.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit f2f083b

Please sign in to comment.