//
//  GradientView.swift
//  1Weather
//
//  Created by Dmitry Stepanets on 12.11.2020.
//

import UIKit

class GradientView: UIView {
    init() {
        super.init(frame: .zero)
        prepare()
    }
    
    required init?(coder: NSCoder) {
        super.init(coder: coder)
        prepare()
    }
    
    override class var layerClass: AnyClass {
        return CAGradientLayer.self
    }
}

//MARK:- Prepare
private extension GradientView {
    func prepare() {
        self.backgroundColor = .clear
        
        guard let gradientLayer = self.layer as? CAGradientLayer else { return }
        gradientLayer.colors = [UIColor(hex: 0x535252).withAlphaComponent(0.14).cgColor,
                                UIColor.black.withAlphaComponent(0.5).cgColor]
        gradientLayer.locations = [0.0, 0.7]
    }
}
