一. 图片准备工作
1. iPhone8 750 × 1334
2. iPhone8p 1242 × 2208
3. iPhoneX 1125 × 2436
4. iPhoneXR 828 × 1792
5. iPhoneXSMAX 1242 × 2688
二. imageset图片准备工作
Contents.json文件修改如下:
{
"images" : [
{
"idiom" : "iphone",
"scale" : "1x"
},
{
"idiom" : "iphone",
"filename" : "iPhone8.png",
"scale" : "2x"
},
{
"idiom" : "iphone",
"scale" : "3x"
},
{
"idiom" : "iphone",
"subtype" : "retina4",
"scale" : "1x"
},
{
"idiom" : "iphone",
"subtype" : "retina4",
"scale" : "2x"
},
{
"idiom" : "iphone",
"subtype" : "retina4",
"scale" : "3x"
},
{
"idiom" : "iphone",
"filename" : "iPhone8p.png",
"subtype" : "736h",
"scale" : "3x"
},
{
"idiom" : "iphone",
"filename" : "iPhone8.png",
"subtype" : "667h",
"scale" : "2x"
},
{
"idiom" : "iphone",
"filename" : "iPhoneX.png",
"subtype" : "2436h",
"scale" : "3x"
},
{
"idiom" : "iphone",
"filename" : "iPhoneXSMax.png",
"subtype" : "2688h",
"scale" : "3x"
},
{
"idiom" : "iphone",
"filename" : "iPhoneXR.png",
"subtype" : "1792h",
"scale" : "2x"
}
],
"info": {
"version" : 1,
"author" : "xcode"
}
}
并将5张图片导入到该imageset下。
三. LaunchScreen.storyboard的修改
1. 新建一个imageView,讲图片设置到imageView上
storyboard如果找不到对应的图片,查下Contents.json里是否有如下代码:
{
"idiom" : "iphone",
"filename" : "iPhone8.png",
"scale" : "2x"
}, 紧紧作为占位用
2. storyboard的配置如下约束配置如下
storyboard3. 设置imageview的contentmode为Aspect Fill
storyboard4. 观察每个版本的适配情况,适当修改frame值
storyboard通过Device选择观察适配情况,如果有不正确的地方适当修改
storyboard到此适配过程结束。
四. 参考链接
感谢作者给的启示
网友评论