Если вы предполагаете прикрепить кнопку UIB справа или слева, следуйте приведенному ниже коду
let rightButtonItem = UIBarButtonItem(image: //your Image,
style: .plain,
target: self,
action: #selector(searchButtonAction(sender:)))
rightButtonItem.tintColor = .black // your desired colour
self.navigationItem.rightBarButtonItem = rightButtonItem // if it is Left side then leftBarButtonItem
, тогда действие должно быть похоже на
@objc
func searchButtonAction(sender: UIBarButtonItem) {
let alert = UIAlertController(title: // Your title,
message:// Your message,
preferredStyle: .alert)
alert.addAction(UIAlertAction(title: // Your button Title, style: .default) { _ in
// Your action
})
alert.addAction(UIAlertAction(title: // Your button Title, style: .cancel) { _ in
// Your action
})
alert.view.tintColor = UIColor(asset: Asset.Colors.black)// Your desired Colour
self.present(alert, animated: true)
}