对此很新颖,所以如果太容易,请原谅我。我为我的VC创建了一个渐变背景,从那时起,当我运行该应用程序时,我的故事板上没有任何图像显示。我附上我的代码,并随时纠正我。添加渐变图层会导致图片无法在Xcode中显示
class whoVC: UIViewController {
func setGradientBackground() {
let colorTop = UIColor(red: 119.0/255.0, green: 56.0/255.0, blue: 109.0/255.0, alpha: 2.0).cgColor
let colorBottom = UIColor(red: 185.0/255.0, green: 89.0/255.0, blue: 127.0/255.0, alpha: 2.0).cgColor
let gradientLayer = CAGradientLayer()
gradientLayer.colors = [ colorTop, colorBottom]
gradientLayer.locations = [ 0.0, 1.0]
gradientLayer.frame = self.view.bounds
self.view.layer.addSublayer(gradientLayer)
}
override func viewDidLoad() {
super.viewDidLoad()
setGradientBackground()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
重新排序子层。 –
我该怎么做? – Moises