Here is what I am trying to do:

The screenshot is taken from Iphone:

This is my code:
import UIKit
class GradientController: UIViewController {
@IBOutlet weak var viewBottomBorder: UIView!
lazy var gradient: CAGradientLayer = {
let gradient = CAGradientLayer()
gradient.type = .axial
gradient.colors = [UIColor.clear.cgColor,UIColor.black.cgColor]
gradient.locations = [0, 1]
return gradient
}()
override func viewDidLoad() {
super.viewDidLoad()
gradient.frame = view.bounds
viewBottomBorder.layer.addSublayer(gradient)
}
}
Question: How to show same bottom gradient colour the view?
Can someone please explain to me how to solve this? I've tried to solve this issue but no results yet.

You can save yourself a lot of work and extra code by using a
UIViewsubclass such as this:Now, in Storyboard, set the Custom Class of your
viewBottomBordertoGradientView, and your controller code becomes: