Reputation: 289
I am displaying a popover (Present as Popover) as a dropdown when the user clicks on nav bar title (which is a label + an image). I was not able to set the nav bar title as popover's anchor view. So for anchor view, I added a clear 1x1 button that sits right below the nav bar (button.top = safe area.top)
I am able to position the popover along the y-axis by changing the y value in sourceRect.
popover?.sourceRect = CGRect(x: 0, y: -10, width: 1, height: 1)
It looks good, except I don't want the arrow in the popover. So I added this line of code.
popover?.permittedArrowDirections = UIPopoverArrowDirection(rawValue: 0)
Now, I am not able to position the popover correctly. It doesn't matter what y value I specify in sourceRect, the popover stays at the same place.
What am I doing wrong?
Thanks.
Upvotes: 0
Views: 1104
Reputation: 536057
The problem is that that is not how to suppress the arrow. The right way is to provide a custom UIPopoverBackgroundView that doesn’t draw the arrow.
However it would be better not to do this at all. Popovers have arrows. If you don’t want the arrow, don’t use a popover. Write a custom presented view controller instead.
Upvotes: 7