Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to hide UIContextMenuInteraction/UITargetedPreview black background?

I want to add UIContextMenuInteraction to a UIView with some transparent parts. When user interact with this view, iOS shows this view with a black background.

enter image description here

Is it possible to make those parts transparent or change the color?

like image 687
Ali Samaiee Avatar asked Nov 24 '25 04:11

Ali Samaiee


1 Answers

Simpler solution to change context menu background color

func contextMenuInteraction(_ interaction: UIContextMenuInteraction, previewForHighlightingMenuWithConfiguration configuration: UIContextMenuConfiguration) -> UITargetedPreview? {
    let previewTarget = UIPreviewTarget(container: self, center: <#your-view>.center)
    let previewParams = UIPreviewParameters()
    previewParams.backgroundColor = .clear

    return UITargetedPreview(view: <#your-view>, parameters: previewParams, target: previewTarget)
}
like image 190
MAGiGO Avatar answered Nov 25 '25 20:11

MAGiGO



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!