title: Gradient view not working when added programmatically
body: <p>So my Class looks like this :</p>
  
  <pre><code>import UIKit
  
  class GradientBarView: UIView {
  
    override init(frame: CGRect) { // for using CustomView in code
        super.init(frame: frame)
        commonInit()
  
    }
  
    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
        commonInit()
    }
  
    func commonInit() {
  
        let gradient = CAGradientLayer()
        gradient.frame = bounds
        gradient.startPoint = CGPoint(x: 0, y: 0.5)
        gradient.endPoint = CGPointMake(1, 0.5)
        gradient.colors = [AppColor.SecondaryGreen.CGColor, AppColor.HeritageGreen.CGColor, AppColor.HeritageGreen.CGColor]
        layer.insertSublayer(gradient, atIndex: 0)
  
        translatesAutoresizingMaskIntoConstraints = false
  
    }
  
  }
  </code></pre>
  
  <p>and this is how I use it(in my viewDidLoad)</p>
  
  <pre><code>let gradientBar = GradientBarView(frame: CGRectZero)
  self.view.addSubview(gradientBar)
  </code></pre>
  
  <p>Then add the necessary constraints(which is fine)...so the problem is that the view is just black but if i add it via the Storyboard it works just fine</p>
  
  <p>please help,what am i missing?</p>
  
  <p>Thanks</p>