@@ -121,10 +121,19 @@ final class UIComponentsExampleViewController: UIViewController {
121121
122122}
123123
124+
125+
124126extension UIComponentsExampleViewController : UIContextMenuInteractionDelegate {
125127
126128 func contextMenuInteraction( _ interaction: UIContextMenuInteraction , configurationForMenuAtLocation location: CGPoint ) -> UIContextMenuConfiguration ? {
127- UIContextMenuConfiguration ( identifier: nil , previewProvider: nil ) { ( _) -> UIMenu ? in
129+ UIContextMenuConfiguration ( identifier: nil , previewProvider: {
130+ // let previewView = UIView()
131+ // previewView.backgroundColor = .gray
132+ // previewView.frame = self.view.bounds
133+ // previewView.layer.cornerRadius = 15
134+ // previewView.layer.masksToBounds = true
135+ return UIComponentsExampleViewController ( )
136+ } ) { ( _) -> UIMenu ? in
128137 let action1 = UIAction ( title: " .all " , image: UIImage ( systemName: " bookmark.fill " ) ) { ( _) in
129138 Appearance . messageDisplayStyle = . all
130139 self . barrageList. messages? . removeAll ( )
@@ -170,6 +179,26 @@ extension UIComponentsExampleViewController: UIContextMenuInteractionDelegate {
170179 return menu
171180 }
172181 }
182+
183+ // func contextMenuInteraction(_ interaction: UIContextMenuInteraction, previewForHighlightingMenuWithConfiguration configuration: UIContextMenuConfiguration) -> UITargetedPreview? {
184+ // let previewParams = UIPreviewParameters()
185+ // previewParams.backgroundColor = .clear
186+ // let visiblePath = UIBezierPath(roundedRect: self.view.bounds, cornerRadius: 15)
187+ // previewParams.visiblePath = visiblePath
188+ // return UITargetedPreview(view: self.view, parameters: previewParams)
189+ // }
190+ //
191+ // func contextMenuInteraction(_ interaction: UIContextMenuInteraction, willPerformPreviewActionForMenuWith configuration: UIContextMenuConfiguration, animator: UIContextMenuInteractionCommitAnimating) {
192+ // animator.addAnimations {
193+ // self.view.backgroundColor = .lightGray // 改变消息气泡的背景色以实现高亮效果
194+ // }
195+ //
196+ // animator.addCompletion {
197+ // UIView.animate(withDuration: 0.25) {
198+ // self.view.backgroundColor = .white // 动画完成后恢复原始颜色
199+ // }
200+ // }
201+ // }
173202}
174203
175204extension UIComponentsExampleViewController : BottomAreaToolBarActionEvents , GiftsViewActionEventsDelegate {
0 commit comments