Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIPopoverPresentation without arrow [duplicate]

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.

like image 716
meteorSD Avatar asked Jul 12 '16 08:07

meteorSD


1 Answers

This is what I tackled just a 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

like image 191
mshrestha Avatar answered Nov 15 '22 21:11

mshrestha