meteorSD meteorSD - 1 year ago 264
Swift Question

UIPopoverPresentation without arrow

I am trying to present a UIViewController in an UIPopoverPresentationController but I dont really like the arrow feature. Basically what I want to do is to use an UIPopoverPresentationController without the arrow that comes with it.
I am coding in Swift.

Answer Source

This is what I tackled just few days back. What I did was basically remove the arrow and provided a source rect myself. The source of course had its Y position altered to give it a popover effect without the arrow. Try it, worked like a charm for me.

yourPopoverPresentationController!.permittedArrowDirections = UIPopoverArrowDirection.init(rawValue: 0)
let aView = //Source View that you would provide for the source rect
yourPopoverPresentationController!.sourceView = aView
let position = CGRectMake(aView.bounds.origin.x, aView.bounds.origin.y + 125, aView.bounds.size.width, aView.bounds.size.height)
yourPopoverPresentationController!.sourceRect = position

This resulted in the following effect which was what I required. enter image description here