// Outlets
@IBOutlet weak var topView: UIStackView!
//view did load
override func viewDidLoad() {
super.viewDidLoad()
let topLayer = CAGradientLayer()
topLayer.frame = topView.frame
topLayer.colors = [UIColor(red: 0.13, green: 0.22, blue: 0.35, alpha: 0.80).cgColor , UIColor(red: 0.18, green: 0.26, blue: 0.39, alpha: 1.00).cgColor]
topLayer.locations = [0.0, 1.0]
topView.layer.insertSublayer(topLayer, at: 0)
}
If I use this code and run it on the simulator the layer is not as big as the view. Unfortunately I can not attach a picture to show you how it looks. I want the layer always as big as the view.
Maybe it is clearer now ?
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags: