I have an App which works with stack Views, to create a good looking UI. To make the App even prettier I want to add color gradient for table view cells and other elements which have a fixed size, this is not a problem. For subviews which change the size depending on the device and orientation it is.
This is how I create the gradient color. How can get the CGRect Values of a subview or is there another way to gradient color without using the frame of CAGradientLayer ?
Code Block let topLayer = CAGradientLayer() topLayer.frame = CGRect(x: 0, y: 0, width: 9000, height: 70) 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)
This is how I create the gradient color. How can get the CGRect Values of a subview or is there another way to gradient color without using the frame of CAGradientLayer ?