//1.通过UIImageView设置 self.view.insertSubview(UIImageView.init(image: UIImage.init(named: "123")),at: 0) //2.通过layer的content self.view.layer.contents = UIImage.init(named: "123")?.cgImage self.view.contentMode = UIViewContentMode.scaleToFill原文链接:https://www.f2er.com/swift/320946.html