diff --git a/Sources/KVKCalendar/AllDayEventView.swift b/Sources/KVKCalendar/AllDayEventView.swift index f20a8afa..c2e45291 100644 --- a/Sources/KVKCalendar/AllDayEventView.swift +++ b/Sources/KVKCalendar/AllDayEventView.swift @@ -70,4 +70,22 @@ final class AllDayEventView: UIView { } } +@available(iOS 13.4, *) +extension AllDayEventView: UIPointerInteractionDelegate { + func addPointInteraction() { + let interaction = UIPointerInteraction(delegate: self) + addInteraction(interaction) + } + + public func pointerInteraction(_ interaction: UIPointerInteraction, styleFor region: UIPointerRegion) -> UIPointerStyle? { + var pointerStyle: UIPointerStyle? + + if let interactionView = interaction.view { + let targetedPreview = UITargetedPreview(view: interactionView) + pointerStyle = UIPointerStyle(effect: .highlight(targetedPreview)) + } + return pointerStyle + } +} + #endif diff --git a/Sources/KVKCalendar/Calendar+Extension.swift b/Sources/KVKCalendar/Calendar+Extension.swift index 26fa32a1..baf677ac 100644 --- a/Sources/KVKCalendar/Calendar+Extension.swift +++ b/Sources/KVKCalendar/Calendar+Extension.swift @@ -389,24 +389,4 @@ public extension KVKDequeueProxyProtocol where Self: UICollectionView { extension UITableView: KVKDequeueProxyProtocol {} extension UICollectionView: KVKDequeueProxyProtocol {} -@available(iOS 13.4, *) -extension UIView: UIPointerInteractionDelegate { - - func addPointInteraction() { - let interaction = UIPointerInteraction(delegate: self) - addInteraction(interaction) - } - - public func pointerInteraction(_ interaction: UIPointerInteraction, styleFor region: UIPointerRegion) -> UIPointerStyle? { - var pointerStyle: UIPointerStyle? - - if let interactionView = interaction.view { - let targetedPreview = UITargetedPreview(view: interactionView) - pointerStyle = UIPointerStyle(effect: .highlight(targetedPreview)) - } - return pointerStyle - } - -} - #endif diff --git a/Sources/KVKCalendar/DayCell.swift b/Sources/KVKCalendar/DayCell.swift index e13c3743..bd79516b 100644 --- a/Sources/KVKCalendar/DayCell.swift +++ b/Sources/KVKCalendar/DayCell.swift @@ -152,4 +152,22 @@ class DayCell: UICollectionViewCell { } } +@available(iOS 13.4, *) +extension DayCell: UIPointerInteractionDelegate { + func addPointInteraction() { + let interaction = UIPointerInteraction(delegate: self) + addInteraction(interaction) + } + + public func pointerInteraction(_ interaction: UIPointerInteraction, styleFor region: UIPointerRegion) -> UIPointerStyle? { + var pointerStyle: UIPointerStyle? + + if let interactionView = interaction.view { + let targetedPreview = UITargetedPreview(view: interactionView) + pointerStyle = UIPointerStyle(effect: .highlight(targetedPreview)) + } + return pointerStyle + } +} + #endif diff --git a/Sources/KVKCalendar/EventView.swift b/Sources/KVKCalendar/EventView.swift index 6c6e0438..d4f8663d 100644 --- a/Sources/KVKCalendar/EventView.swift +++ b/Sources/KVKCalendar/EventView.swift @@ -126,4 +126,22 @@ final class EventView: EventViewGeneral { } +@available(iOS 13.4, *) +extension EventView: UIPointerInteractionDelegate { + func addPointInteraction() { + let interaction = UIPointerInteraction(delegate: self) + addInteraction(interaction) + } + + public func pointerInteraction(_ interaction: UIPointerInteraction, styleFor region: UIPointerRegion) -> UIPointerStyle? { + var pointerStyle: UIPointerStyle? + + if let interactionView = interaction.view { + let targetedPreview = UITargetedPreview(view: interactionView) + pointerStyle = UIPointerStyle(effect: .highlight(targetedPreview)) + } + return pointerStyle + } +} + #endif diff --git a/Sources/KVKCalendar/ListViewCell.swift b/Sources/KVKCalendar/ListViewCell.swift index b610010f..0ffd85f1 100644 --- a/Sources/KVKCalendar/ListViewCell.swift +++ b/Sources/KVKCalendar/ListViewCell.swift @@ -86,4 +86,22 @@ final class ListViewCell: KVKTableViewCell { } +@available(iOS 13.4, *) +extension ListViewCell: UIPointerInteractionDelegate { + func addPointInteraction() { + let interaction = UIPointerInteraction(delegate: self) + addInteraction(interaction) + } + + public func pointerInteraction(_ interaction: UIPointerInteraction, styleFor region: UIPointerRegion) -> UIPointerStyle? { + var pointerStyle: UIPointerStyle? + + if let interactionView = interaction.view { + let targetedPreview = UITargetedPreview(view: interactionView) + pointerStyle = UIPointerStyle(effect: .highlight(targetedPreview)) + } + return pointerStyle + } +} + #endif diff --git a/Sources/KVKCalendar/MonthCell.swift b/Sources/KVKCalendar/MonthCell.swift index 59769c30..eecbde6f 100644 --- a/Sources/KVKCalendar/MonthCell.swift +++ b/Sources/KVKCalendar/MonthCell.swift @@ -268,10 +268,6 @@ final class MonthCell: KVKCollectionViewCell { dateLabel.frame = dateFrame dateLabel.tag = defaultTagView contentView.addSubview(dateLabel) - - if #available(iOS 13.4, *) { - contentView.addPointInteraction() - } } required init?(coder aDecoder: NSCoder) { diff --git a/Sources/KVKCalendar/ResizeEventView.swift b/Sources/KVKCalendar/ResizeEventView.swift index 83975d83..427bd480 100644 --- a/Sources/KVKCalendar/ResizeEventView.swift +++ b/Sources/KVKCalendar/ResizeEventView.swift @@ -144,7 +144,7 @@ final class ResizeEventView: UIView { } @available(iOS 13.4, *) -extension ResizeEventView { +extension ResizeEventView: UIPointerInteractionDelegate { func pointerInteraction(_ interaction: UIPointerInteraction, regionFor request: UIPointerRegionRequest, defaultRegion: UIPointerRegion) -> UIPointerRegion? { if topView.frame.contains(request.location) { @@ -156,6 +156,20 @@ extension ResizeEventView { } } + func addPointInteraction() { + let interaction = UIPointerInteraction(delegate: self) + addInteraction(interaction) + } + + public func pointerInteraction(_ interaction: UIPointerInteraction, styleFor region: UIPointerRegion) -> UIPointerStyle? { + var pointerStyle: UIPointerStyle? + + if let interactionView = interaction.view { + let targetedPreview = UITargetedPreview(view: interactionView) + pointerStyle = UIPointerStyle(effect: .highlight(targetedPreview)) + } + return pointerStyle + } } protocol ResizeEventViewDelegate: AnyObject { diff --git a/Sources/KVKCalendar/ScrollableWeekView.swift b/Sources/KVKCalendar/ScrollableWeekView.swift index 4344c895..4ffc229b 100644 --- a/Sources/KVKCalendar/ScrollableWeekView.swift +++ b/Sources/KVKCalendar/ScrollableWeekView.swift @@ -277,7 +277,6 @@ extension ScrollableWeekView: CalendarSettingProtocol { if #available(iOS 14.0, *) { cornerBtn.showsMenuAsPrimaryAction = true - cornerBtn.addPointInteraction() cornerBtn.menu = createTimeZonesMenu() if style.selectedTimeZones.count > 1 { diff --git a/Sources/KVKCalendar/YearCell.swift b/Sources/KVKCalendar/YearCell.swift index 27d20371..c35bada0 100644 --- a/Sources/KVKCalendar/YearCell.swift +++ b/Sources/KVKCalendar/YearCell.swift @@ -202,4 +202,22 @@ final class YearCell: UICollectionViewCell { } } +@available(iOS 13.4, *) +extension YearCell: UIPointerInteractionDelegate { + func addPointInteraction() { + let interaction = UIPointerInteraction(delegate: self) + addInteraction(interaction) + } + + public func pointerInteraction(_ interaction: UIPointerInteraction, styleFor region: UIPointerRegion) -> UIPointerStyle? { + var pointerStyle: UIPointerStyle? + + if let interactionView = interaction.view { + let targetedPreview = UITargetedPreview(view: interactionView) + pointerStyle = UIPointerStyle(effect: .highlight(targetedPreview)) + } + return pointerStyle + } +} + #endif