diff --git a/Sources/Menu Cells/Overlay/OverlayMenuCell.swift b/Sources/Menu Cells/Overlay/OverlayMenuCell.swift index c406085..9268816 100644 --- a/Sources/Menu Cells/Overlay/OverlayMenuCell.swift +++ b/Sources/Menu Cells/Overlay/OverlayMenuCell.swift @@ -94,6 +94,10 @@ public class OverlayMenuCell: PagingMenuViewCell { func setFrame(_ menuView: PagingMenuView, maskFrame: CGRect, animated: Bool) { textMaskView.frame = menuView.convert(maskFrame, to: highlightLabel).inset(by: maskInsets) + + if let expectedOriginX = menuView.getExpectedAlignmentPositionXIfNeeded() { + textMaskView.frame.origin.x += expectedOriginX + } } public func calculateWidth(from height: CGFloat, title: String) -> CGFloat { diff --git a/Sources/PagingMenuView.swift b/Sources/PagingMenuView.swift index eeac8d1..c136132 100644 --- a/Sources/PagingMenuView.swift +++ b/Sources/PagingMenuView.swift @@ -652,12 +652,23 @@ open class PagingMenuView: UIScrollView { /// If contentSize.width is not over safe area, paging menu view applys cellAlignment to each the cells. private func alignContainerViewIfNeeded() { - let expectedOriginX = cellAlignment.calculateOriginX(from: maxSafedOffset) - guard !hasScrollableArea && expectedOriginX != containerView.frame.origin.x else { + guard let expectedOriginX = getExpectedAlignmentPositionXIfNeeded() else { return } - - containerView.frame.origin.x = expectedOriginX + + if expectedOriginX != containerView.frame.origin.x { + containerView.frame.origin.x = expectedOriginX + } + } + + + /// get correct origin X of menu view's container view, If menu view is scrollable. + func getExpectedAlignmentPositionXIfNeeded() -> CGFloat? { + let expectedOriginX = cellAlignment.calculateOriginX(from: maxSafedOffset) + guard !hasScrollableArea else { + return nil + } + return expectedOriginX }