gpt4 book ai didi

ios - 如何指定弹出 Controller 的箭头指向的位置

转载 作者:行者123 更新时间:2023-11-29 11:34:36 24 4
gpt4 key购买 nike

众所周知,为了使用 preferredStyle: .actionSheet 呈现 UIAlertController,使用下一个代码设置 anchor 是一个很好的做法:

 popover.sourceView = view
popover.sourceRect = view.bounds

在我的例子中, View 是 UIImageView,它的大小是 44x44,但是它的图像(三个垂直点)非常细(它的大小是 4x24)。所以 View 大部分是透明的。结果,弹出窗口“指向”空白区域。 (请注意,我使用红色来显示完全透明的区域)

enter image description here

理想情况下,弹出窗口的箭头应指向中央的白点。但我不知道如何实现它。我尝试修改 sourceRect 如下:

popover.sourceRect = CGRect(x: view.bounds.midX - 1,
y: view.bounds.midY - 1,
width: 2,
height: 2)

但由于某种原因它指向顶部的白点:

enter image description here

如何让它指向所需的点?

最佳答案

sourceRect 对我有用,我只是使用 y 坐标定位箭头,它对我有用。

popover.sourceRect =  CGRect(x: 0, y: yourPosition, width: 0, height: 0)

你也可以看看this .

关于ios - 如何指定弹出 Controller 的箭头指向的位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50489288/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com