关于ios:UIPopoverPresentation没有箭头

UIPopoverPresentation without arrow

本问题已经有最佳答案,请猛点这里访问。

我试图在UIPopoverPresentationController中显示一个UIViewController,但我真的不喜欢箭头功能。

基本上我想做的是使用它随附的UIPopoverPresentationController without the arrow

我正在用Swift编写代码。


这是几天前我解决的问题。我所做的基本上是删除箭头,并自己提供一个消息来源。当然,更改了源的Y位置,使其在没有箭头的情况下具有弹出效果。尝试一下,对我来说就像是一种魅力。

1
2
3
4
5
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

这产生了我需要的以下效果。
enter