[英]Image Fit 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")!)
}
}
這樣可以成功加載圖像,但我只想確保它將在從iPhone 6到iPhone 6 Plus的任何屏幕尺寸上加載
不要將背景設置為圖案。 只需在所有其他視圖后面添加一個UIImageView
。 將其contentMode
設置為scaleAspectFill
並將其image
設置為"BestBackground"
圖像。 您可以在情節提要或代碼中完成所有這些操作。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.