简体   繁体   English

适用于iPad和iPhone的iOS图像尺寸

[英]iOS image sizes for iPad and iPhone

I have developed an small iOS app, where i have image named bg.png which is of dimension 我开发了一个小型的iOS应用程序,其中我有一个名为bg.png的 image

1024 * 768 for iPad. 适用于iPad的1024 * 768。

Now i have many images which has been created for iPad size. 现在我有许多为iPad尺寸创建的图像。 Now i need to make support of this app in iPhone, for that weather i need to create same set of images agian for iPhone size, 现在我需要在iPhone中支持这个应用程序,因为那个天气我需要为iPhone大小创建相同的图像集,

568 * 300 for iPhone. 适用于iPhone的568 * 300。

or there is another way to do this? 还是有另一种方法可以做到这一点?

Scaling down the iPad image assets will destroy UX on iPhone. 缩小iPad图像资产将破坏iPhone上的UX。 Also images like icon, splash screen usually contain company logo. 图标,启动画面等图像通常包含公司徽标。 Scaling down will tamper the look of the logo and overall image. 向下缩小将篡改徽标和整体图像的外观。 Better way is to create separate images for iPhone form factor. 更好的方法是为iPhone外形创建单独的图像。 Trim the png files using http://tinypng.org/ to keep binary size low. 使用http://tinypng.org/修剪png文件以保持低二进制文件大小。

Cheers! 干杯!
Amar. 阿马尔。

You can use this code to re-size the image by following code, 您可以使用此代码通过以下代码重新调整图像大小,

CGSize newSize = CGSizeMake(568, 300);
UIGraphicsBeginImageContext(newSize);
[yourIpadImage drawInRect:CGRectMake(0, 0, newSize.width, newSize.height)];
newIphoneImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
   + (UIImage *)imageWithImage:(UIImage *)image scaledToSize:(CGSize)newSize {
        //UIGraphicsBeginImageContext(newSize);
        UIGraphicsBeginImageContextWithOptions(newSize, NO, 0.0);
        [image drawInRect:CGRectMake(0, 0, newSize.width, newSize.height)];
        UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();    
        UIGraphicsEndImageContext();
        return newImage;
    }

You have option to change the Size of Your Image 您可以选择更改图像的大小

sathiamoorthys solution is a difficult way or rescaling your image. sathiamoorthys解决方案是一种困难的方式或重新调整你的形象。 You can do that by simply creating a UIImageView, initialize it with a UIImage and then change its frame. 您可以通过简单地创建UIImageView,使用UIImage对其进行初始化然后更改其框架来实现。 Note that your image will look scaled/distorted that way. 请注意,您的图像会以这种方式缩放/扭曲。

follow this: 按照这个:

  1. open the image in preview. 在预览中打开图像。

  2. go to tools > adjust size 转到工具>调整大小

  3. put in whatever size you want. 放入你想要的任何尺寸。

  4. save the image as a different name. 将图像另存为其他名称。

yes you should create duplicate and resize them for iphone. 是的你应该创建副本并为iPhone调整大小。 Using same images for iphone will bring memory issues because the images are unnecessarily big for iphone. 为iphone使用相同的图像会带来内存问题,因为iPhone的图像不必要大。

Use any software to resize them or you can do this using preview also as Nikita described above 使用任何软件来调整它们的大小,或者您也可以使用preview来执行此操作, 如上所述

If you are doing this to create universal app then you must postfix ~ipad in the name of the image file. 如果您这样做是为了创建通用应用程序,那么您必须在图像文件的名称中使用postfix ~ipad

Please visit this link , May help you and solve your issue. 请访问此链接 ,可以帮助您并解决您的问题。

There is the some tips like: 有一些提示,如:

  1. Propotional scale, 比例尺,
  2. Resize 调整

If you want your images to show up unscaled, you are going to need an additional image with the correct size. 如果您希望图像显示为非缩放图像,则需要具有正确尺寸的其他图像。 So supporting both iPad with and without retina screens would require one image of 768x1024 and one of 1536 x 2048. For iPhone 3.5" you would need 960 x 640 when it is a retina screen or 480 x 320 when it is non-retina. For iPhone 5 (4" screen) you would need 568 x 320. If you use UIImages method imageNamed: there is help from Apple. 因此,支持带有和不带视网膜屏幕的iPad都需要一张768x1024和1536 x 2048的图像。对于iPhone 3.5“,当它是视网膜屏幕时需要960 x 640,或者当它是非视网膜时需要480 x 320。 iPhone 5(4“屏幕)你需要568 x 320.如果你使用UIImages方法imageNamed:Apple有帮助。 It loads on retina devices that method looks for the the image you specified with the postfix '@2x'. 它加载在视网膜设备上,该方法查找使用后缀“@ 2x”指定的图像。 So you can simply code: UIImage * myImage = [UIImage imageNamed: @"myImage"] If you make sure you project contains myImage.png for non-retina devices and myImage@2x.png for retina devices the right image gets loaded at runtime. 所以你可以简单地编码: UIImage * myImage = [UIImage imageNamed: @"myImage"]如果你确定你的项目包含非视网膜设备的myImage.png和视网膜设备的myImage@2x.png,那么右边的图像会在运行时被加载。

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

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