UINavigationBar的图像大小是多少 [英] What is the size of the image for UINavigationBar

查看:76
本文介绍了UINavigationBar的图像大小是多少的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一共有三个模拟器或iPhone设备,如下所示

There are three simulator or iPhone devices, as given below

iPhone

iPhone (Retina 3.5 inch)

iPhone (Retina 4 inch)

我想为导航栏实现以下方法.

I want to implement the following method, for navigation bar.

- (UINavigationController *)navigationController {

    nav = [[UINavigationController alloc]
           initWithRootViewController:[self demoController]];

    // If Iphone/iPod Touch
    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
        // If iPhone 5 or new iPod Touch

        NSLog(@"The height is %f ", [UIScreen mainScreen].bounds.size.height );

        NSLog(@"The width is %f ", [UIScreen mainScreen].bounds.size.width);


        if([UIScreen mainScreen].bounds.size.height == 568){
            [nav.navigationBar setBackgroundImage:[UIImage imageNamed:@"nav.png"] forBarMetrics: UIBarMetricsDefault];
        } else{
            // Regular iPhone
            [nav.navigationBar setBackgroundImage:[UIImage imageNamed:@"nav_classic.png"] forBarMetrics: UIBarMetricsDefault];

        }
    }

    return nav;

}

我想知道导航图像,nav.png和条件的正确大小,以便我可以在所有三种设备上使用.

I want to know proper size of Navigation image, nav.png, and condition, so that i can work for all three devices.

当我将320x44用于nav classic时,但在设备 iPhone(3.5英寸视网膜)中看起来很小 因此,当我全部使用nav.png时,它看起来更大 iPhone

As I used 320x44 for nav classic, but it looks small in device iPhone (Retina 3.5 inch) So, As I use nav.png for all, its looks bigger iPhone

1. UINavigationBar的合适大小是什么?

2.使用它们的正确逻辑是什么?

谢谢

推荐答案

iphone 3.5视网膜和iphone 4视网膜的导航栏大小没有区别.该视网膜设备的图像实际大小为640x88.您还可以为导航栏制作两张图像,一张为320x44(对于非视网膜设备),另一张为640x88.您必须将此图像命名为NavImage.png和NavImage@2x.png,这样操作系统将自动使用正确的图像.

There's no difference in the size of the navigation bar for iphone 3.5 retina and iphone 4 retina. The real size of the image for this retina devices is 640x88. You can also made two images for the navigation bar one at 320x44 (for non retina devices) and one at 640x88. You have to name this image something like NavImage.png and NavImage@2x.png , in this way the os will automaticcaly use the correct image.

这篇关于UINavigationBar的图像大小是多少的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆