Question: Tried this but only works for UIButton:

```
[btn setTarget:self action:@selector(btnClicked:) forControlEvents:UIControlEventTouchUpInside];

```

Answer: 
For a custom `UIBarButtonItem` this works.

```
let button = UIButton(type: .custom)
button.setImage(image, for: .normal)
button.addTarget(self, action: #selector(yourFunction), for: .touchUpInside)
let barButtonItem = UIBarButtonItem(customView: button)

```

You set the target and action to the button that you are adding to your `UIBarButtonItem`.
You may want to try out the addTarget method.