Vahid Vahid - 7 months ago 38
iOS Question

How to find center coordinate of UINavigationBar item

I need to show some popover and for that I need position of right navigation bar button. currently I used

x = self.view.frame.width - 30
y = self.view.frame.origin.y + 60

But I think It's not a good way, Because iPad screen in landscape view the view.frame.origin.y is a bit diff to iPhone in the same situation.


You can get it like this

if let rightBarButton = self.navigationItem.rightBarButtonItem {
    if rightBarButton.valueForKey("view") != nil {
            // here you can access the frame like this buttonView.frame