Created
April 8, 2020 19:22
-
-
Save SpectralDragon/e1c01388db09752eac790ae23f1d4587 to your computer and use it in GitHub Desktop.
Simple way to implement preview context menu for SwiftUI
@jalvini @acal11 It looks like the white overlay can be fixed by adding these to Coordinator
:
func contextMenuInteraction(_ interaction: UIContextMenuInteraction, previewForHighlightingMenuWithConfiguration configuration: UIContextMenuConfiguration) -> UITargetedPreview? {
let parameters = UIPreviewParameters()
parameters.backgroundColor = .clear
return UITargetedPreview(view: interaction.view!, parameters: parameters)
}
func contextMenuInteraction(_ interaction: UIContextMenuInteraction, previewForDismissingMenuWithConfiguration configuration: UIContextMenuConfiguration) -> UITargetedPreview? {
let parameters = UIPreviewParameters()
parameters.backgroundColor = .clear
return UITargetedPreview(view: interaction.view!, parameters: parameters)
}
what if we have a button in the preview. how action should be triggered? cause now buttons are not working
what if we have a button in the preview. how action should be triggered? cause now buttons are not working
I did it only for previewing :) You could not interact with it at the moment, but if you know how to improve this solution, you're welcome!
The animation when long pressing does not appear but it is a good attempt and does not screw up my layout like other methods! Would appreciate an update to the code where the animation can appear just like Apple's implementation!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@jalvini did you ever manage to resolve this?