简体   繁体   English

适用于所有屏幕尺寸的iOS全屏背景图像

[英]iOS full screen background image for all screen sizes

I'm trying to set a background image for my app that will scale to fill the 4, 4.7, and 5.5 inch screens. 我正在尝试为我的应用设置一个背景图像,可以缩放以填充4,4.7和5.5英寸的屏幕。

  • I'm working in XCode 6 with swift 我正在使用swift在XCode 6中工作
  • I created a 640 x 1136 image, and pasted @1x, @2x, and @3x images in my images.xcasetts folder. 我创建了一个640 x 1136图像,并在我的images.xcasetts文件夹中粘贴了@ 1x,@ 2x和@ 3x图像。 I selected the 'scale to fill' mode for the image view. 我为图像视图选择了“缩放到填充”模式。
  • I created a UIImage in the main.storyboard file for the 4 inch screen. 我在4英寸屏幕的main.storyboard文件中创建了一个UIImage。 This image fills the screen just fine when I build. 当我构建时,这个图像填满了屏幕。
  • I think I've tried just about every combination of height / width / aspect ratio constraints with no luck. 我想我已经尝试了几乎所有高度/宽度/长宽比约束的组合而没有运气。

The 4 and 4.7 use @2x, 5.5 used @3x, please see the screenshot detail. 4和4.7使用@ 2x,5.5使用@ 3x,请参阅屏幕截图详细信息。

截图

You can download the PDF that is the origin of this screenshot from Ugur Akdemir's Dribble . 您可以从Ugur Akdemir的Dribble下载作为此屏幕截图原点的PDF。

You can use this solution: http://codemotionapps.com/get-assets-ready-ios8-iphone-6-plus/ 您可以使用此解决方案: http//codemotionapps.com/get-assets-ready-ios8-iphone-6-plus/

。

I created vector gradient in free Inkscape editor and export to PDF (my PDF file size is 4Kb). 我在免费的Inkscape编辑器中创建了矢量渐变并导出为PDF(我的PDF文件大小为4Kb)。 Then I add this PDF to Images.xcassets in my project and selected it. 然后我将此PDF添加到我的项目中的Images.xcassets并选择它。 In Attributes inspector for Scale Factors choose Single Vector. 在“比例因子”的“属性”检查器中,选择“单向量” When the app is compiled the PDF generates PNGs for all nesesery resolutions @1x, @2x, @3x and others :-) 编译应用程序时,PDF会为所有nesesery分辨率@ 1x,@ 2x,@ 3x和其他人生成PNG :-)

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

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