没有箭头的UIPopoverPresentation [重复]

问题描述 投票:8回答:1

这个问题在这里已有答案:

我试图在UIViewController呈现UIPopoverPresentationController,但我真的不喜欢箭头功能。

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

我在Swift编写代码。

ios iphone swift xcode uipopovercontroller
1个回答
20
投票

这是我几天前刚刚解决的问题。我所做的基本上是删除箭头并自己提供了一个源矩阵。当然,来源的Y位置被改变,以使其具有不带箭头的弹出效果。尝试一下,对我来说就像一个魅力。

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 image description here

© www.soinside.com 2019 - 2024. All rights reserved.