Post

Replies

Boosts

Views

Activity

Reply to Close button doesn't work in UIKit?
Adding a small UIView overlay in the corner with a UITapGestureRecognizer worked for me: let tipVC = TipUIPopoverViewController( tip, sourceItem: view, actionHandler: { action in actionHandler?(action.id) }) // Create the UIView let tapView = UIView() tapView.translatesAutoresizingMaskIntoConstraints = false // Enable Auto Layout tapView.backgroundColor = .clear // Set background color if needed // Add the UITapGestureRecognizer let tapGesture = UITapGestureRecognizer(target: tipVC, action: #selector(dismissModal)) tapView.addGestureRecognizer(tapGesture) // Add the view to the tipVC tipVC.view.addSubview(tapView) // Set up constraints NSLayoutConstraint.activate([ tapView.widthAnchor.constraint(equalToConstant: 32), tapView.heightAnchor.constraint(equalToConstant: 32), tapView.topAnchor.constraint(equalTo: tipVC.view.topAnchor, constant: 8), // Adjust if needed tapView.trailingAnchor.constraint(equalTo: tipVC.view.trailingAnchor, constant: -8) // Adjust if needed ]) You'll also need a selector, for example: extension UIViewController { @objc func dismissModal() { dismiss(animated: true) } }
Aug ’24