diff --git a/Example/SJVideoPlayer.xcworkspace/xcuserdata/changsanjiang.xcuserdatad/UserInterfaceState.xcuserstate b/Example/SJVideoPlayer.xcworkspace/xcuserdata/changsanjiang.xcuserdatad/UserInterfaceState.xcuserstate index cce6f9968..44a1d3f89 100644 Binary files a/Example/SJVideoPlayer.xcworkspace/xcuserdata/changsanjiang.xcuserdatad/UserInterfaceState.xcuserstate and b/Example/SJVideoPlayer.xcworkspace/xcuserdata/changsanjiang.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/SJVideoPlayer/Common/Utils/Adapters/SJEdgeControlLayerAdapters.m b/SJVideoPlayer/Common/Utils/Adapters/SJEdgeControlLayerAdapters.m index 082206063..3e71ce445 100644 --- a/SJVideoPlayer/Common/Utils/Adapters/SJEdgeControlLayerAdapters.m +++ b/SJVideoPlayer/Common/Utils/Adapters/SJEdgeControlLayerAdapters.m @@ -60,9 +60,12 @@ - (BOOL)isFitOnScreen { - (void)layoutSubviews { [super layoutSubviews]; - + [self _updateLayoutIfNeeded]; + _centerAdapter.itemFillSizeForFrameLayout = self.bounds.size; +} + +- (void)_updateLayoutIfNeeded { CGRect curr = self.bounds; - if ( _screen.is_iPhoneX && _autoAdjustLayoutWhenDeviceIsiPhoneX ) { if ( !CGRectEqualToRect(_beforeBounds, curr) ) { CGFloat viewW = curr.size.width; @@ -78,13 +81,9 @@ - (void)layoutSubviews { } } } - else { - if ( !CGRectEqualToRect(_beforeBounds, curr) ) { - [self _updateTopLayout:nil]; - } + else if ( !CGRectEqualToRect(_beforeBounds, curr) ) { + [self _updateTopLayout:nil]; } - - _centerAdapter.itemFillSizeForFrameLayout = curr.size; _beforeBounds = curr; } @@ -180,7 +179,7 @@ - (void)_observeOrientationChangeOfStatusBarNotify { - (void)_updateTopLayout:(nullable NSNotification *)notify { if ( !_topAdapter ) return; - if ( _screen.is_iPhoneX ) return; + if ( _screen.is_iPhoneX && _autoAdjustLayoutWhenDeviceIsiPhoneX ) return; [UIView animateWithDuration:0 animations:^{} completion:^(BOOL finished) { UIInterfaceOrientation orientation = notify?[notify.userInfo[UIApplicationStatusBarOrientationUserInfoKey] integerValue]: UIApplication.sharedApplication.statusBarOrientation; switch ( orientation ) { @@ -431,7 +430,7 @@ - (void)setRightWidth:(CGFloat)rightWidth { - (void)setTopMargin:(CGFloat)topMargin { _topMargin = topMargin; - [self _updateTopLayout:nil]; + [self _updateLayoutIfNeeded]; } - (void)setLeftMargin:(CGFloat)leftMargin {