没有箭头的UIPopoverPresentation

12

我想在 UIPopoverPresentationController 中展示一个 UIViewController,但我不太喜欢它带有的箭头功能。

基本上,我想使用一个没有带有箭头的 UIPopoverPresentationController

我正在使用 Swift 编程。


据我所知,您无法在没有箭头的情况下使用UIPopoverPresentationController。唯一的方法是使用/创建其他类。 - Shadow Of
你能告诉我在哪里/搜索什么吗? - meteorSD
2
不行,我喜欢那个箭头,抱歉 :D - Shadow Of
1
@ShadowOf 你绝对可以做到。我已经为你发布了答案。保持积极,没有什么是你做不到的。 :) - mshrestha
@ManjulShrestha 很好!那我的评论就没用了 =) - Shadow Of
1
@ShadowOf 并不是故意这样做的。干杯 :) - mshrestha
1个回答

25

就在几天前,我解决了这个问题。我的做法基本上是去掉箭头,并且自己提供一个源矩形。当然,源的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

这导致了我需要的以下效果。 在此输入图片描述


箭头对我来说出现在视图的顶部 - Rajan M

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接