It's well known that in order to present UIAlertController
with preferredStyle: .actionSheet
, it's a good practice to set an anchor using the next code:
popover.sourceView = view
popover.sourceRect = view.bounds
In my case, the view is UIImageView
, it's size is 44x44, but its image (three vertical dots) is very thin (its size is 4x24). So the view is mostly transparent. As a result, popover "points" to empty space. (Note that I am using red color to show fully transparent area)
Ideally, popover's arrow should point to the central white dot. But I do not know how to achieve it. I tried to modify sourceRect
as follows:
popover.sourceRect = CGRect(x: view.bounds.midX - 1,
y: view.bounds.midY - 1,
width: 2,
height: 2)
but it points to the top white dot for some reason:
How can I make it pointing to the desired point?