'Tap area of UIBarButtonItem is smaller than its CustomView

I have a UIBarButtonItem with a UIView inside (let's say container) containing a UIImageView and another UIView for showing notification state. The container also has a UITapGestureRecognizer. But the problem is that taps work only in a small area of this view. I set constraints and frame size for the container, but it didn't work. What may cause the issue and how can I resolve it?

UIBarButtonItem with a tap area



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source