Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use a barButtonItem as source #69

Open
xcodewarrier opened this issue May 7, 2016 · 4 comments
Open

Use a barButtonItem as source #69

xcodewarrier opened this issue May 7, 2016 · 4 comments
Labels

Comments

@xcodewarrier
Copy link

Is it possible to use this with a UIBarButtonItem?

leftBarButtonItem could be hacked as it will always be on the top left of the view, but what abut a rightBarButtonItem?

@andreamazz
Copy link
Owner

Hi @xcodewarrier
There is not a best way to approach this as far as I know, just hacks that call the private view of the button: http://stackoverflow.com/questions/14318368/uibarbuttonitem-how-can-i-find-its-frame

@mknippen
Copy link

+1

This would be a great feature to add a way to support this. It's a rather common use case.

@uknowmeright
Copy link

try this:

private func frameForTabAtIndex(index: Int) -> CGRect {
    guard let tabBarSubviews = tabBarController?.tabBar.subviews else {
        return CGRect.zero
    }
    var allItems = [UIView]()
    for tabBarItem in tabBarSubviews {
        if tabBarItem.isKind(of: NSClassFromString("UITabBarButton")!) {
            allItems.append(tabBarItem)
        }
    }
    let item = allItems[index]
    return item.superview!.convert(item.frame, to: view)
}

@Yagnik13
Copy link

I have the same query as @xcodewarrier. Any update on it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants