Vic*_*ico 0 iphone uinavigationbar ios
我正在尝试调整我的iphone 6应用程序.
在将自定义背景图像设置到导航栏之前,一切运行良好:
[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"navbarbg.png"] forBarMetrics:UIBarMetricsDefault];
Run Code Online (Sandbox Code Playgroud)
由于此图像是为iphone 4/5制作的,因此宽度不足.
你知道如何为iphone6设置正确的图像吗?
我试图将我的图像命名为navbarbg@3x.png或navabarbg-667h@3x.png,但它不会改变任何内容.
任何的想法 ?
更新:我添加了我使用的图像:

也许这也有帮助,它的工作正常(如果您的图像阴影或不同)您也可以使用这个,但您必须根据设备的比例设置不同的图像:
NSLog(@"width is :%f",[[UIScreen mainScreen] bounds].size.width);
UIImage *navBarImage =nil;
if ([[UIScreen mainScreen] bounds].size.width==375.0f) {
navBarImage = [[UIImage imageNamed: @"header-topbg-iphone6@2x"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0)];
}
else if ([[UIScreen mainScreen] bounds].size.width==414.0f) {
navBarImage = [[UIImage imageNamed: @"header-topbg-iphone6plus@3x"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0)];
}
else{
navBarImage = [[UIImage imageNamed: @"header-topbg"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0)];
}
[[UINavigationBar appearance] setBackgroundImage:navBarImage forBarMetrics:UIBarMetricsDefault];
Run Code Online (Sandbox Code Playgroud)
你可以看到iphone6 +的下图:
谢谢.
| 归档时间: |
|
| 查看次数: |
2950 次 |
| 最近记录: |