GradientView.swift 853 Bytes
//
//  GradientView.swift
//  browser
//
//  Created by Artem Talko on 22.11.2023.
//

import UIKit

class GradientView: UIView {
    private let gradientViewLayer = CAGradientLayer()
    
    override init (frame: CGRect) {
        super.init(frame: frame)
        
        mainViewGradientSetup()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override func layoutSubviews() {
        super.layoutSubviews()
        
        gradientViewLayer.frame = self.bounds
    }
    
    private func mainViewGradientSetup() {
        self.layer.insertSublayer(gradientViewLayer, at: 0)
        gradientViewLayer.colors = [
            UIColor(red: 0, green: 0, blue: 0, alpha: 1).cgColor,
            UIColor(red: 0.337, green: 0.537, blue: 0.949, alpha: 1).cgColor
        ]
    }
}