UIPopoverController从BarButtonItem呈现弹出窗口:...偏离中心

3
我正在从一个条形按钮项中展示一个弹出窗口,但是弹出窗口的箭头在水平方向上并不居中于该项下方: presenting popover from bar button item 我想将其向左移动几个像素。
这并不会在所有UIBarButtonItem实例上发生,仅在我使用自定义图像创建时才会发生。因此,例如,最右侧的按钮项具有完美居中的箭头,并且它是使用系统项实例化的:
[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(shareButtonWasPressed:)]

但是,如果我使用自定义图像,

[[UIBarButtonItem alloc] initWithImage:slideshowImage style:UIBarButtonItemStylePlain target:self action:@selector(slideshowButtonWasPressed:)]

...它偏离中心。我尝试调整按钮项的imageInsets,但它会拉伸图像。有什么建议吗?

1个回答

0
原来实现这个最简单的方法是实现你自己的UIPopoverBackgroundView子类,并使用它来调整箭头显示的位置。这涉及到大量的自定义绘图代码,如果没有设计师的帮助,我无法完成它,但我们想要一个自定义背景,所以这是值得的。
仍然不知道如何在没有可争议的解决方法的情况下修复这个问题。

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