美文网首页iOS开发
iOS设备尺寸、AppIcon以及LaunchImage使用添加

iOS设备尺寸、AppIcon以及LaunchImage使用添加

作者: 罂粟之城 | 来源:发表于2019-01-31 00:00 被阅读6次

    iOS设备,顾名思义包括 iPhoneiPad 两类苹果设备。

    随着苹果公司对于新设备的不断开发,从原先的小屏幕 iPhone4s/iPad mini 到现在的 全面屏(带刘海哈) iPhone Xs Max,设备尺寸也在不断增加,所以对于iOS开发程序员来说,也是需要不断的进行相应的适配,当然适配就需要我们了解每款型号设备的尺寸像素以便可以做到正确的尺寸适配。

    1. 苹果各个设备尺寸

    iPhone设备尺寸:

        iPhone 4/4S              --- 开发尺寸: 320×480pt -- 分辨率: 640×960px -- 操作系统:iOS4/iOS5 
        iPhone 5/5S/5c       --- 320×568pt -- 640×1136px -- iOS6/iOS7/iOS8
        iPhone 6/6S/7        --- 375×667pt -- 750×1334px -- iOS8/iOS9/iOS10
        iPhone 6Plus/6S Plus/7 Plus --- 414×736pt -- 1080×1920px -- iOS8/iOS9/iOS10
        iPhone SE                --- 320×568pt  --  -- iOS9
        iPhone X && iPhone XS    --- 375×812pt (20+34pt--顶部多20,底部多34) -- &1125x2436px& -- 切图: @3x && @3x
        iPhone XR && iPhone XS Max  --- 414x896pt -- 828x1792px && 1242x2688px --  切图:@2x && @3x
    

    针对iOS切图,以 iPhone7即750x1334px像素值为基准制作设计图,然后程序根据所给设计图进行相应的适配。当然对于新产生的 iPhoneX/iPhoneXS/iPhoneXR/iPhoneXSMax这几种全面屏机型(存在刘海屏),可能需要针对做出不同的界面设计。

    iPad设备尺寸及主要开发尺寸

        iPad Pro    --- 12.9 inch   -- 分辨率: 2732*2048px
        iPad Pro    --- 10.5 inch --    2224*1668
        iPad        --- 9.7 inch -- 2048*1536
        iPad mini   --- 7.9 inch -- 2048*1536
    但是对于以上iPad型号只使用一种iPad开发尺寸即可(对于正常iPad)
        **** 768*1024 pt ****
        区别对待: 
         iPad pro(12.9 inch)/iPad pro(12.9- 第二代)/iPad pro(10.5 inch)/iPad pro(9.7 inch)...
    

    iPad 设备运行iPhone应用 -- 当项目没有设置可以在iPad上运行时,若运行在iPad上显示iPhone尺寸:

        除了iPad Pro 12.9 inch是对应输出iPhone 5s尺寸大小(即 320-568 pt)
        其他iPad尺寸全部加载iPhone应用都是iPhone 4s尺寸(即 320-480 pt)
    

    如下图详细介绍了区分了 iPhone / iPad 各个机型和尺寸:

    iPhone设备尺寸.png iPad设备尺寸.png 各个分别率介绍.png
    >> 如果需要自动适应各种iPhone设备的屏幕,则需要先获取屏幕大小,在根据屏幕大小来调整应用界面。如下代码获取屏幕大小:
        CGRect screenRect=[UIScreen mainScreen].bounds;
        若需要进行输出:
            1,则可以把CGRect类型转化为字符串类型进行输出,调用语句:NSString* screenRectStr = NSStringFromCGRect(screenRect);
            2,或者直接使用NSLog语句进行一个个调用输出:screenRect.origin.x, screenRect.origin.y,screenRect.size.width, screenRect.size.height
    
    >> 判断 iPhoneiPad 设备中一些 宏定义使用
        #define kScreenWidth [UIScreen mainScreen].bounds.size.width
        #define kScreenHeight [UIScreen mainScreen].bounds.size.height
        #define kSetScreenBounds CGRectMake(0, 0, kScreenWidth, kScreenHeight)
    
        #define kIsPhone [[UIDevice currentDevice]userInterfaceIdiom] == UIUserInterfaceIdiomPhone
        #define kIsPad [[UIDevice currentDevice]userInterfaceIdiom] == UIUserInterfaceIdiomPad
        
    判断设备系统宏定义:
        #define iOS8 [[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0
        #define kiOSVersionStartAvailable(x) @available(iOS x,*) // iOS x,以上及其版本使用
    
    iPhone设备判断宏定义:
        #define kIsiPhone5s  (kScreenWidth == 320.f && kScreenHeight == 568.f)
        #define kIsiPhone7And8 (kScreenWidth == 375.f && kScreenHeight == 667.f) // <==>8
        #define kIsiPhone7PAnd8P (kScreenWidth == 414.f && kScreenHeight == 736.f) // <==>8P
        #define kIsiPhoneXSMaxAndXR  (kScreenWidth ==414.f  && kScreenHeight ==896.f)
        #define kIsiPhoneXAndXS   (kScreenWidth == 375.f && kScreenHeight == 812.f)
    
    设备适配比例计算宏定义
        #define kScreenWidthScale [UIScreen mainScreen].bounds.size.width/375.0  //7屏幕适配宽度比例系数
        #define kScreenHeightScale [UIScreen mainScreen].bounds.size.height/667.0 //7屏幕适配高度比例系数
    

    2.iOS AppIcon

    iOS制作的软件的App图标是用来显示,当然是要显示在iPhone/iPad中的很多地方的。

    如iPhone屏幕界面的启动icon、设置里 Bundle的 icon、通知里的icon,当然这些icon的大小不一样的。

    如何添加? 添加步骤如下:

    • 1、首先选中需要更换或添加AppIcon的项目 在 TARGETS--> General --> App Icons and Launch Images --> App Icon Source 选择一个 asset catalogs
    • 2、 asset catalogs 是在 Images.xcassets 中创建的或已经存在的需要添加的应用图标 icon

    可详见图片


    AppIcon添加.png
    Apple官方文档对App Icon添加

    iOS app图标自动生成----图标工场 http://icon.wuruihong.com/ 网站导入 1024x1024px 自动生成iOS所需的所有对应格式的图标,只需各个尺寸一一拖入即可使用

    3. iOS App LaunchImage 添加使用

    iOS App LaunchImage应用的启动图片的设置类似于 iOS AppIcon 设置,操作步骤如下:

    1. 首先选中需要更换或添加AppIcon的项目 在 TARGETS--> General --> App Icons and Launch Images --> Launch Images Sourc 选择一个 asset catalogs
    2. asset catalogs 是在 Images.xcassets 中创建的或已经存在的需要添加 App Launch Images
    iOS_LaunchImagesSize.png

    相关文章

      网友评论

        本文标题:iOS设备尺寸、AppIcon以及LaunchImage使用添加

        本文链接:https://www.haomeiwen.com/subject/jwvhsqtx.html