UIPopoverController 更改 UIPopoverArrowDirection 的位置
我想将 UIPopoverArrowDirection
移至左侧,以便实际箭头不再居中,而是从左侧多出 25%,从右侧多出 75%。
为了帮助理解我的意思,请查看两个屏幕截图,我希望它像第二个一样...
< img src="https://i.sstatic.net/DqVCu.png" alt="带有我想要的正确放置箭头的 Popover">
问题是没有真正的方法来深入研究 popover 类。 。
I want to move the UIPopoverArrowDirection
to the left such that the actual arrow is no longer centered but more 25% from the left and 75% from the right.
To help understand what I mean see the two screen shots I want it to be like the second one...
The problem is that there is no real way to dig down into the popover class...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
通过指定“presentPopoverFromRect”并使该矩形受到足够的约束,这已经可以通过内置类实现。
下面是直接从上述代码中取出的代码。额外的绒毛是因为小齿轮位于 UINavigationBar 的 UIToolbar 中。
r
是 UIToolbar 的框架,它正在被调整以击中正确的位置(箭头),否则会稍微偏离中心。MGSettingsView
是视图控制器(其中包含“启用过渡”、“启用夜间模式”等)。如果这不是您所要求的,我认为您最好重新表述您的问题。 :)
This is already doable with the builtin class by specifing "presentPopoverFromRect" and making that rect constrained enough.
The below is code taken straight out of the code that results in the above. The extra fluff is because the little cogwheel thing is in a UIToolbar in a UINavigationBar.
r
is the frame of the UIToolbar and it's being tweaked to hit the right spot (for the arrow) or it'd be slightly off-center.MGSettingsView
is the view controller (with "Enable transitions", "Enable night mode", etc in it).If this isn't what you're asking for you'd better rephrase your question I think. :)
UIPopoverController 类提供了一个简单的从坐标(矩形)显示内容的方法。您可以设置要自动执行的
popoverArrowDirection
,仅此而已。根据这些信息,系统将自动显示弹出窗口以适合屏幕并尊重您想要的方向,您不能要求更多。The UIPopoverController class provides a simple way to display content from coordinates (Rect). You have the ability to set the
popoverArrowDirection
you want to autorize, and that's it. From these informations, the system will automatically display the popover to fit in screen and respect the directin you want, you can not ask for more.检查下面的方法,您可以给出 arrowDirections 方向的矩形。
Check below method in this you can give the rect for the arrowDirections direction.