简体   繁体   English

自定义导航栏图像周围的白色像素

[英]White pixels around custom navigation bar image

In my iOS 5+ app, I use a custom navigation bar image, with custom navbar buttons. 在我的iOS 5+应用中,我使用带有自定义导航栏按钮的自定义导航栏图像。

First of all, here is how I tell my app to use the images : 首先,这是我告诉我的应用使用图像的方式:

In AppDelegate.m : AppDelegate.m

UIImage *navBarImage = [UIImage imageNamed:@"Navbar"];
[[UINavigationBar appearance] setBackgroundImage:navBarImage forBarMetrics:UIBarMetricsDefault];

UIImage *barButton = [[UIImage imageNamed:@"Nav-button"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 6, 0, 6)];
[[UIBarButtonItem appearance] setBackgroundImage:barButton forState:UIControlStateNormal
                                      barMetrics:UIBarMetricsDefault];

So, the images are used. 因此,使用图像。 Great. 大。 But, there are a couple of things happening : 但是,发生了几件事:

• First, on my button, under the bottom corners, au few white pixels appear (they're not on the original image, that's for sure). •首先,在我的按钮的底角下,出现了几个白色像素(这是肯定的,它们不在原始图像上)。 I also use a custom back button, and same thing happens. 我还使用了自定义的后退按钮,同样的事情也会发生。 This seems to be more visible under iOS 6 than iOS 5. 在iOS 6下,这似乎比iOS 5更为明显。

• When I open a modal VC, the navigation bar is "filled up to the status bar" with white pixels. •打开模态VC时,导航栏“充满状态栏”中带有白色像素。 Only for a modal VC. 仅用于模式VC。

Here are screenshots of the situation. 这是情况的屏幕截图。

iOS 5-主要

iOS 5 , main VC. iOS 5,主要VC。

iOS 5-模式

iOS 5, modal VC. iOS 5,模态VC。

iOS 6-主要

iOS 6, main VC. iOS 6,主要VC。

iOS 6-模态

iOS 6, modal VC. iOS 6,模态VC。

So, what can I do ? 那么,我该怎么办? The white pixels under the buttons are not highly visible (a bit more for the back button), but I really want a nice design for the app, and this doesn't contribute at all.. 按钮下方的白色像素不太明显(后退按钮更多),但是我确实想要为该应用程序提供一个不错的设计,而这完全没有帮助。

Concerning the modal VC, I can use a "rectangle" image, which could cover the white pixels, but again, regarding design consistency, I'd prefer to use only one navigation bar.. 关于模态VC,我可以使用“矩形”图像,该图像可以覆盖白色像素,但是关于设计一致性,我宁愿只使用一个导航栏。

As always, any explanation / solution / hint is greatly appreciated ! 与往常一样,任何解释/解决方案/提示都将不胜感激! ;) ;)

Thanks. 谢谢。


EDIT : 编辑:

I just noticed that under iOS 6, the white pixels on top of the navigation bar are rounded, as the navigation bars in iOS 6.. Strange.. :) 我刚刚注意到,在iOS 6下,导航栏顶部的白色像素是圆形的,与iOS 6中的导航栏一样。

Hm! 哼! just for testing purpose, can you download the following sample image for a navigation bar background and try this image instead? 仅出于测试目的,您可以下载以下示例图像作为导航栏背景并尝试使用该图像吗? Just let us now how it looks with this image. 现在让我们看一下此图像的外观。

I'm just guessing, but i suppose your image is not pixel perfect for the navigation bar dimensions! 我只是在猜测,但我想您的图像对于导航栏尺寸而言并不是像素完美的! Probably a few pixels below the optimum height for the navigation bar. 可能比导航栏的最佳高度低几个像素。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM