diff --git a/ios/Classes/BetterPlayer.m b/ios/Classes/BetterPlayer.m index 119f11c10..a5d269f71 100644 --- a/ios/Classes/BetterPlayer.m +++ b/ios/Classes/BetterPlayer.m @@ -852,11 +852,7 @@ - (void) showLimitedBlackCoverView { [self._betterPlayerView addSubview:_limitedBlackCoverView]; - NSArray *commonConstraints = [self._betterPlayerView.constraints filteredArrayUsingPredicate:[NSPredicate predicateWithBlock:^BOOL(NSLayoutConstraint *constraint, NSDictionary *bindings) { - return [constraint.secondItem isEqual:_limitedBlackCoverView] || [constraint.firstItem isEqual:_limitedBlackCoverView]; - }]]; - - if (commonConstraints.count > 0) { + if ([self hasCommonConstraintsBetweenTwoViews:self._betterPlayerView andView2:_limitedBlackCoverView]) { return; } @@ -868,6 +864,14 @@ - (void) showLimitedBlackCoverView { ]]; } +- (BOOL)hasCommonConstraintsBetweenTwoViews:(UIView *)view1 andView2:(UIView *)view2 { + NSArray *commonConstraints = [view1.constraints filteredArrayUsingPredicate:[NSPredicate predicateWithBlock:^BOOL(NSLayoutConstraint *constraint, NSDictionary *bindings) { + return [constraint.firstItem isEqual:view2] || [constraint.secondItem isEqual:view2]; + }]]; + + return commonConstraints.count > 0; +} + - (void) hideLimitedBlackCoverView { if (_limitedBlackCoverView) { [_limitedBlackCoverView removeFromSuperview]; @@ -947,11 +951,7 @@ - (void) showLimitedPlanCoverViewInPIP { if (window && _isPipMode) { [window addSubview:_limitedPlanCoverView]; - NSArray *commonConstraints = [window.constraints filteredArrayUsingPredicate:[NSPredicate predicateWithBlock:^BOOL(NSLayoutConstraint *constraint, NSDictionary *bindings) { - return [constraint.secondItem isEqual:_limitedPlanCoverView] || [constraint.firstItem isEqual:_limitedPlanCoverView]; - }]]; - - if (commonConstraints.count > 0) { + if ([self hasCommonConstraintsBetweenTwoViews:window andView2:_limitedPlanCoverView]) { return; }