diff --git a/Sources/TGCardViewController/TGCardViewController.swift b/Sources/TGCardViewController/TGCardViewController.swift index 2d4a945..9423d48 100644 --- a/Sources/TGCardViewController/TGCardViewController.swift +++ b/Sources/TGCardViewController/TGCardViewController.swift @@ -1676,8 +1676,10 @@ extension TGCardViewController { UIView.animate(withDuration: animated ? 0.25: 0) { self.topFloatingViewWrapper.alpha = fade ? 0 : 1 self.topFloatingViewWrapper.isUserInteractionEnabled = !fade + self.topFloatingViewWrapper.isAccessibilityElement = !fade self.bottomFloatingViewWrapper.alpha = fade ? 0 : 1 self.bottomFloatingViewWrapper.isUserInteractionEnabled = !fade + self.bottomFloatingViewWrapper.isAccessibilityElement = !fade } } diff --git a/Sources/TGCardViewController/TGCardViewController.xib b/Sources/TGCardViewController/TGCardViewController.xib index c434eae..1f8b506 100644 --- a/Sources/TGCardViewController/TGCardViewController.xib +++ b/Sources/TGCardViewController/TGCardViewController.xib @@ -1,9 +1,9 @@ - + - + @@ -52,13 +52,13 @@ - + @@ -82,19 +82,19 @@ - + - + - + - + - + @@ -107,7 +107,7 @@ - + @@ -130,7 +130,7 @@ - + diff --git a/Sources/TGCardViewController/cards/TGPageCardView.swift b/Sources/TGCardViewController/cards/TGPageCardView.swift index 4d0f216..1decc99 100644 --- a/Sources/TGCardViewController/cards/TGPageCardView.swift +++ b/Sources/TGCardViewController/cards/TGPageCardView.swift @@ -38,6 +38,12 @@ class TGPageCardView: TGCardView { (contentView.subviews as? [TGCardView]) ?? [] } + private func cardView(index: Int) -> TGCardView? { + let cardViews = self.cardViews + guard index >= 0, index <= cardViews.count else { return nil } + return cardViews[index] + } + override var preferredView: UIView { cardViews.first?.preferredView ?? self } @@ -136,6 +142,8 @@ class TGPageCardView: TGCardView { // This will be used in both `moveForward` and `moveBackward`, so // it's important to "initailise" this value correctly. lastHorizontalOffset = CGFloat(pageCard.initialPageIndex) * (frame.width + Constants.spaceBetweenCards) + + self.accessibilityElements = [cardView(index: pageCard.initialPageIndex)].compactMap { $0 } } override func updateDismissButton(show: Bool, isSpringLoaded: Bool) { @@ -206,6 +214,10 @@ class TGPageCardView: TGCardView { } func moveForward(animated: Bool = true) { + // Assign `visiblePage` here so that we allow paging there even if VoiceOver is enabled + visiblePage = min(cardViews.count - 1, visiblePage + 1) + self.accessibilityElements = [cardView(index: visiblePage)].compactMap { $0 } + // Shift by the entire width of the card view let nextFullWidthHorizontalOffset = pager.contentOffset.x + frame.width + Constants.spaceBetweenCards @@ -230,6 +242,10 @@ class TGPageCardView: TGCardView { } func moveBackward(animated: Bool = true) { + // Assign `visiblePage` here so that we allow paging there even if VoiceOver is enabled + visiblePage = max(0, visiblePage - 1) + self.accessibilityElements = [cardView(index: visiblePage)].compactMap { $0 } + // See `moveForward()` for comments. let nextFullWidthHorizontalOffset = pager.contentOffset.x - frame.width - Constants.spaceBetweenCards let nextFullPageHorizontalOffset = lastHorizontalOffset - frame.width - Constants.spaceBetweenCards @@ -246,9 +262,12 @@ class TGPageCardView: TGCardView { func move(to cardIndex: Int, animated: Bool = true) { // index must fall within the range of available content cards. guard 0..