2017-08-07 15:19:52 u010454583 阅读数 310

由于今年来Apple发布的设备越来越多,设备的AppIcon和LaunchImage涉及到的尺寸越来越多,搜索的结果也是各种混乱,这里做一个整理。

iPad

Direction Status Bar Size
Portait No 768 x 1004
Have 768 x 1024
Landscape No 1024 x 748
Have 1024 x 768

iPhone

Direction Property Size
Portait Retina HD 5.5 1242 x 2208
Retina 4 640 x 1136
Retina HD 4.7 750 x 1134
1x [1] 320 x 480
Landscape Retina HD 5.5 1242 x 2208
1x [2] 1024 x 768

[1]: iPad 1倍图
[2]: iPhone 1倍图

2019-11-13 21:42:20 chuanyue11 阅读数 71

IOS图片生成工具(@1X,@2X,@3X)

在进行IOS开发过程中,经常需要为了适配不同分辨率的设备而准备不同尺寸的图片。由于本人长期从事后台研发工作,对前端及UI常用工具(比如PS)并不熟悉,于是开发了下面这个工具对一个大尺寸的图片进行裁剪,生成1倍、2倍、3倍尺寸的图片,方便进行IOS开发。

工具介绍

该工具接受两个参数,分别为源图片文件或目录和目标图片存放文件夹。源图片为分辨率高于所有裁剪结果图片的分辨率(@1X,@2X,@3X)。

裁剪结果图片的尺寸写在ResizeImage类开头处,可以根据需要进行修改。

工具代码

package tools;

import common.Base;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.util.Arrays;

/**
 * Genarate @1X, @2X, @3X pictures.
 *
 * @author zjm
 */
public class ResizeImage extends Base {
    private static final Logger LOGGER = LoggerFactory.getLogger(ResizeImage.class);

    /**
     * {width, height}
     */
    //    private static final int[] SIZE_3X = new int[] { 300, 402 };
    //    private static final int[] SIZE_2X = new int[] { 200, 268 };
    //    private static final int[] SIZE_1X = new int[] { 100, 134 };
    private static final int[] SIZE_3X = new int[] { 300, 300 };
    private static final int[] SIZE_2X = new int[] { 200, 200 };
    private static final int[] SIZE_1X = new int[] { 100, 100 };

    private String srcFileOrDirctory;
    private String destDirectory;

    public ResizeImage() {

    }

    public ResizeImage(String srcFileOrDirctory, String destFileOrDirectory) {
        this.srcFileOrDirctory = srcFileOrDirctory;
        this.destDirectory = destFileOrDirectory;
    }

    public String getSrcFileOrDirctory() {
        return srcFileOrDirctory;
    }

    public void setSrcFileOrDirctory(String srcFileOrDirctory) {
        this.srcFileOrDirctory = srcFileOrDirctory;
    }

    public String getDestDirectory() {
        return destDirectory;
    }

    public void setDestDirectory(String destDirectory) {
        this.destDirectory = destDirectory;
    }

    public void resizeImage() throws Exception {
        LOGGER.debug("Resize image parameters: src - {}, dest - {}", srcFileOrDirctory, destDirectory);

        File src = new File(srcFileOrDirctory);

        File dest = new File(destDirectory);
        if (dest.exists() && dest.isFile()) {
            throw new IllegalArgumentException("Not a directory: " + dest);
        }
        dest.mkdirs();

        if (src.exists() && src.isDirectory()) {
            File[] images = src.listFiles();
            for (File image : images) {
                resizeImage(srcFileOrDirctory, destDirectory);
            }
        } else if (src.exists() && src.isFile()) {
            resizeImage(srcFileOrDirctory, destDirectory);
        } else {
            throw new IllegalArgumentException("No such file or directory: " + src);
        }
    }

    private void resizeImage(String src, String dest) throws Exception {
        File destImage;

        destImage = new File(dest, getTypePrefix(src) + "@3X." + getTypeAppendix(src));
        resizeImage(src, destImage.getAbsolutePath(), SIZE_3X);

        destImage = new File(dest, getTypePrefix(src) + "@2X." + getTypeAppendix(src));
        resizeImage(src, destImage.getAbsolutePath(), SIZE_2X);

        destImage = new File(dest, getTypePrefix(src) + "@1X." + getTypeAppendix(src));
        resizeImage(src, destImage.getAbsolutePath(), SIZE_1X);
    }

    private void resizeImage(String src, String dest, int[] size) throws Exception {
        LOGGER.debug("Resizing image {} to {} in size {} ...", src, dest, Arrays.toString(size));

        BufferedImage srcImage = ImageIO.read(new File(src));

        BufferedImage destImage = new BufferedImage(size[0], size[1], srcImage.getType());
        Graphics2D destGraph = destImage.createGraphics();
        destGraph.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
        destGraph.drawImage(srcImage, 0, 0, size[0], size[1], 0, 0, srcImage.getWidth(), srcImage.getHeight(), null);
        destGraph.dispose();

        ImageIO.write(destImage, getTypeAppendix(src), new File(dest));

        LOGGER.debug("A new image {} is created.", dest);
    }

    private String getTypeAppendix(String image) {
        int lastIndex = image.lastIndexOf(".");
        return image.substring(lastIndex + 1);
    }

    private String getTypePrefix(String image) {
        int lastSlashIndex = image.lastIndexOf("/");
        int lastDotIndex = image.lastIndexOf(".");
        return image.substring(lastSlashIndex + 1, lastDotIndex);
    }

    public static void main(String[] args) throws Exception {
        if (args.length != 2) {
            LOGGER.error("Invalid arguments. Usage: {} <source image file or directory> <dest image directory>",
                    ResizeImage.class.getSimpleName());
            System.exit(1);
        }
        new ResizeImage(args[0], args[1]).resizeImage();
    }
}

2015-07-27 15:32:03 M_nao 阅读数 26134

    1x,2x就是用于非Retain屏幕和Retain屏幕,3x现在用于iPhone6 Plus,在iPhone实际开发中,只有iPhone4 是非Retain屏幕,市场占有率很低,因此在切图时,只切@2x和@3x图片即可。以iphone 6做UI为例,如果图片大小为200*200px,例如图片命名为test_a@2x.png,那么还应切一张命名为test_a@3x.png的300*300px的图片来适配iPhone 6Plus。这样程序在运行时就能根据不同设备自动调用不同图片,从而达到最佳效果。

附一张原理图:


2019-01-21 12:25:56 u012852597 阅读数 425

如下表格所示:

系统版本 型号 图片尺寸 倍图
iPhone Portrait iOS 7+ 2X 640 × 960 @2x
Retina 4 640 × 1136 @2x
iPhone Portrait iOS 8+ Retina HD 5.5″ 1242 × 2208 @3x
Retina HD 4.7″ 750 × 1334 @2x
Portrait iOS 11+ iPhone X / iPhone Xs 1125 × 2436 @3x
Portrait iOS 12+ iPhone Xs Max 1242 × 2688 @3x
iPhone Xʀ 828 × 1792 @2x

示例:
在这里插入图片描述

2016-08-29 16:42:07 huayongsheng198511 阅读数 40
注意:iOS所有图标的圆角效果由系统生成,给到的图标本身不能是圆角的。

1. 桌面图标 (app icon)
for iPhone6 plus(@3x) : 180 x 180
for iPhone 6/5s/5/4s/4(@2x) : 120 x 120
2. 系统搜索框图标 (Spotlight search results icon)
for iPhone6 plus(@3x) : 120 x 120
for iPhone6/5s/5/4s/4(@2x) : 80 x 80
3. 系统设置图标 (Settings icon)
for iPhone6 plus(@3x) : 87 x 87
for iPhone6/5s/5/4s/4(@2x) : 58 x 58
4. 启动图片 (launch image)
for iPhoen5s/5(@2x) : 640 x 1136
for iPhoen4s/4(@2x) : 640 x 960

iPhone6/iPhone6 plus 建议使用 launch file 或 storyboard ;如果依然想使用图片,尺寸数值为:

for iPhone 6(@2x) : 750 x 1334

for iPhone 6 plus (@3x) : 1242 x 2208


文/简述呢(简书作者)
原文链接:http://www.jianshu.com/p/adpKye
著作权归作者所有,转载请联系作者获得授权,并标注“简书作者”。

iOS-Appicon尺寸

阅读数 351

没有更多推荐了,返回首页