Vahid Vahid - 1 year ago 75
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.

Answer Source

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
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download