title: How to get the frame of UIBarButtonItem with respect to UIWindow in Swift?
body: <p>I have gone through a lot of SO posts on this topic. But I have a different requirement.</p>
  
  <p>Am working on an <strong>App Walkthrough</strong> page in my app for which i would like to display some hints over some of the UI objects. I would like to place a UIView above the entire page to blur it out and then display highlighted image and a hint text. For that reason, I need the frame of those objects(for which help is required) with respect to the UIWindow so that i can place another highlighted image exactly above them. I have found the frame of a couple of objects inside the header of a tableview with the following code.</p>
  
  <pre><code>//Hint for expand/collapse arrow
  guard let deviceHeaderView: StatusSectionView = tblStatus.headerView(forSection: 0) as? StatusSectionView else {
      //Hide expand/collapse hint objects
  }
  
  if let imgExpandCollapseFrame = deviceHeaderView.imgExpandCollapse.superview?.convert(deviceHeaderView.imgExpandCollapse.frame, to: window) {
      print("Frame of imgExpandCollapse.. \(imgExpandCollapseFrame)")
  
      let xPosition = (imgExpandCollapseFrame.origin.x + (imgExpandCollapseFrame.size.width/2)) - appWalkthroughView.downArrowHintImgView.frame.size.width/2
  
      let yPosition = (imgExpandCollapseFrame.origin.y + (imgExpandCollapseFrame.size.height/2)) - appWalkthroughView.downArrowHintImgView.frame.size.height/2
  
      appWalkthroughView.downArrowHintImgView.frame = CGRect(x: xPosition,
                                                             y: yPosition,
                                                             width: appWalkthroughView.downArrowHintImgView.frame.size.width,
                                                             height: appWalkthroughView.downArrowHintImgView.frame.size.height)
  }
  </code></pre>
  
  <p>Similarly, I need to find the frame of the UIBarButtonItem and convert its frame with respect to the UIWindow and display hint image above it. </p>
  
  <p>For that, I have found the frame of the UIBarButtonItem like this,</p>
  
  <pre><code>let leftBarButtonItem = self.navigationItem.leftBarButtonItem!
  
  if let leftBarButtonItemView = leftBarButtonItem.value(forKey: "view") as? UIView {
      print(leftBarButtonItemView.frame)
  }
  </code></pre>
  
  <p>This code just gives the bounds of the bar button item like this.</p>
  
  <pre><code>(0.0, 0.0, 36.0, 44.0)
  </code></pre>
  
  <p>And i couldn't convert its frame with respect to UIWindow. How can we achieve this?</p>