简体   繁体   English

适合任何屏幕的图像

[英]Image Fit Any Screen

Hi I am making a simple login screen for my app in xCode and want to make sure that it fits any screen 嗨,我正在使用xCode为我的应用程序制作一个简单的登录屏幕,并希望确保它适合任何屏幕

import UIKit

class LoginController: UIViewController {

override func viewDidLoad() {
    super.viewDidLoad()

    // Do any additional setup after loading the view.
    // will allow me to put a image as my UI background instead of a color
    self.view.backgroundColor = UIColor(patternImage: UIImage(named:"BestBackground")!)
}

} }

This successfully loads the image but i just want to make sure it will load on any screen size from iPhone 6 to iPhone 6 Plus 这样可以成功加载图像,但我只想确保它将在从iPhone 6到iPhone 6 Plus的任何屏幕尺寸上加载

Don't set the background to a pattern. 不要将背景设置为图案。 Just add a UIImageView behind all the other views. 只需在所有其他视图后面添加一个UIImageView Set its contentMode to scaleAspectFill and set its image to your "BestBackground" image. 将其contentMode设置为scaleAspectFill并将其image设置为"BestBackground"图像。 You can do all of this is the storyboard or in code. 您可以在情节提要或代码中完成所有这些操作。

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

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