ios – Gradient Colour Not Properly worked on UIView Swift


Here is what I am trying to do:

original screen shot

The screenshot is taken from Iphone:

trying give result

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.

Any help would be greatly appreciated.

Thanks in advance.

Latest articles

spot_imgspot_img

Related articles

Leave a reply

Please enter your comment!
Please enter your name here

spot_imgspot_img