我从条形按钮项目中呈现一个弹出窗口,弹出窗口的箭头没有在该项目下方水平居中:
我想将它向左移动几个像素。
它不会出现在所有 UIBarButtonItem
实例上,只有在我使用自定义图像创建时才会出现。因此,例如,最右边的按钮项有一个完全居中的箭头,它是使用系统项实例化的:
[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(shareButtonWasPressed:)]
但是如果我使用自定义图片,
[[UIBarButtonItem alloc] initWithImage:slideshowImage style:UIBarButtonItemStylePlain target:self action:@selector(slideshowButtonWasPressed:)]
...它偏离了中心。我试过调整按钮项的 imageInsets
,但它拉伸(stretch)了图像。有什么建议吗?
最佳答案
事实证明,最简单的方法是实现您自己的 UIPopoverBackgroundView
子类,并使用它来调整显示箭头的位置。这涉及到很多自定义绘图代码,没有设计师我无法完成,但无论如何我们都想要一个自定义背景,所以这是值得的。
如果没有有争议的变通办法,我仍然不知道如何解决这个问题。
关于ios - UIPopoverController presentPopoverFromBarButtonItem :. .. 偏心,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9808081/