diff --git a/Sources/TGCardViewController/cards/TGCardView.swift b/Sources/TGCardViewController/cards/TGCardView.swift index 9e63d0c..2fcafb2 100644 --- a/Sources/TGCardViewController/cards/TGCardView.swift +++ b/Sources/TGCardViewController/cards/TGCardView.swift @@ -10,12 +10,13 @@ import UIKit public protocol TGInteractiveCardTitle: UIView { - /// This method returns a frame that covers the interactive area of a card title in a + /// This method returns frames that cover the interactive areas of a card title in a /// `TGCardView`. If the card title does not contain interactive components, this - /// method should return `nil`. + /// method should return an empty array. + /// /// - Parameter cardView: The parent view that contains the card title. This /// is typically a subclass of `TGCardView` - func interactiveFrame(relativeTo cardView: TGCardView) -> CGRect? + func interactiveFrames(relativeTo cardView: TGCardView) -> [CGRect] } @@ -159,10 +160,11 @@ public class TGCardView: TGCornerView, TGPreferrableView { func interactiveTitleContains(_ point: CGPoint) -> Bool { guard let titlePlaceholder = titleViewPlaceholder, - let interactiveTitle = titlePlaceholder.subviews.first as? TGInteractiveCardTitle, - let interactiveFrame = interactiveTitle.interactiveFrame(relativeTo: self) + let interactiveTitle = titlePlaceholder.subviews.first as? TGInteractiveCardTitle else { return false } - return interactiveFrame.contains(point) + + let frames = interactiveTitle.interactiveFrames(relativeTo: self) + return frames.contains { $0.contains(point) } } func headerHeight(for position: TGCardPosition) -> CGFloat { diff --git a/Sources/TGCardViewController/views/TGCardDefaultTitleView.swift b/Sources/TGCardViewController/views/TGCardDefaultTitleView.swift index 4f6429a..3f150af 100644 --- a/Sources/TGCardViewController/views/TGCardDefaultTitleView.swift +++ b/Sources/TGCardViewController/views/TGCardDefaultTitleView.swift @@ -129,9 +129,9 @@ class TGCardDefaultTitleView: UIView, TGPreferrableView { extension TGCardDefaultTitleView: TGInteractiveCardTitle { - func interactiveFrame(relativeTo cardView: TGCardView) -> CGRect? { - guard let accessory = accessoryViewContainer.subviews.first else { return nil } - return accessoryViewContainer.convert(accessory.frame, to: cardView) + func interactiveFrames(relativeTo cardView: TGCardView) -> [CGRect] { + guard let accessory = accessoryViewContainer.subviews.first else { return [] } + return [accessoryViewContainer.convert(accessory.frame, to: cardView)] } }