2

UIView 是一个用于关闭 UIViewController 的 topBar。如果 topBar 没有动画,它显示和隐藏得很好。但是当一个幻灯片动画被添加到 topBar 时,它会在动画执行时闪烁。

奇怪的是,如果我暂停 AVPlayer,topBar 的动画效果很好,每次点击屏幕时,topBar 都会正确显示和隐藏幻灯片动画。

为什么 AVPlay 的播放或暂停状态会影响 tapBar(AVPlayer 上的 UIView)的行为?

我怎样才能使动画效果很好? UIView 和 AVPlayer 的截图

    __weak typeof(self) weakSelf = self;

    CGRect topBarViewFrame  = weakSelf.topBarView.frame;

    if( self.topBarView.hidden ){

        // show control UIView
        self.topBarView.hidden  = NO;
        self.controlView.hidden = NO;

        [UIView animateWithDuration:0.35f animations:^{

            __strong typeof(weakSelf) strongSelf = weakSelf;

            strongSelf.topBarView.frame = CGRectMake( topBarViewFrame.origin.x, 0, topBarViewFrame.size.width, topBarViewFrame.size.height);

            strongSelf.controlView.alpha = 1.0f;

        } completion:nil];


    }else{

        // hide control UIView

        [UIView animateWithDuration:0.35f  animations:^{

            __strong typeof(weakSelf) strongSelf = weakSelf;

            strongSelf.topBarView.frame = CGRectMake( topBarViewFrame.origin.x, - topBarViewFrame.size.height, topBarViewFrame.size.width, topBarViewFrame.size.height);

            strongSelf.controlView.alpha = 0.0f;

        } completion:^(BOOL finished) {

            __strong typeof(weakSelf) strongSelf = weakSelf;

            strongSelf.topBarView.hidden  = YES;
            strongSelf.controlView.hidden = YES;

        }];

    }
4

0 回答 0