andreamazz / AMPopTip

An animated popover that pops out a given frame, great for subtle UI tips and onboarding.
MIT License
3.21k stars 441 forks source link

Use a barButtonItem as source #69

Open xcodewarrier opened 8 years ago

xcodewarrier commented 8 years ago

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 commented 8 years ago

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 commented 7 years ago

+1

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

uknowmeright commented 6 years ago

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 commented 3 years ago

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