對此很新穎,所以如果太容易,請原諒我。我爲我的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