title: Center Swift Pop-Over on screen
body: <p>I am currently working on an app that requieres the user profiles to be shown as a pop-over when the user picture is pressed. I managed to get this behaviour using UIPopoverPresentationControllerDelegate but I would like your help entering this pop-over in the middle of the screen.</p>
  
  <p><a href="https://i.stack.imgur.com/BP8m6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BP8m6.png" alt="current and desired behaviour"></a></p>
  
  <p>My code looks like:</p>
  
  <pre><code>    func presentProfile(sender: UIButton){
  
              let storyboard : UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
              let vc = storyboard.instantiateViewControllerWithIdentifier("profileVC") as! ProfileViewController
  
              vc.profilePicture =  (self.contentIdToImage[content.hostId as! String]?.image)!
  
              vc.modalPresentationStyle = UIModalPresentationStyle.Popover
  
              let height = self.view.bounds.size.height
              let width = self.view.bounds.size.width
  
              vc.preferredContentSize = CGSizeMake(width * 0.8, height * 0.8)
  
              if let presentationController = vc.popoverPresentationController {
                  presentationController.delegate = self
                  presentationController.permittedArrowDirections =  UIPopoverArrowDirection(rawValue: 0)
                  presentationController.sourceView = sender
  
                  self.presentViewController(vc, animated: true, completion: nil)
              }
  
      }
  </code></pre>
  
  <p>Thank you</p>
  
  <p><strong>Edit:</strong></p>
  
  <p>Based on the first answer I received I started playing around with CGRect and I think the desired behaviour can be achieved using the "sourceRect" property of the UIPopoverPresentationController but I have not figure it out.</p>