title: Applying Gradient on UIView not getting expected result
body: <p>I just simply want to apply Gradient with 2 UIColors that's why I written below code.</p>
  
  <pre><code>class Constants: NSObject {
      class func applyGradient(localView:UIView, color1:UIColor, color2:UIColor) {
          let gradient: CAGradientLayer = CAGradientLayer()
          gradient.frame = localView.bounds
          gradient.colors = [color1.CGColor, color2.CGColor]
          gradient.startPoint = CGPoint(x: 0,y: 0)
          gradient.endPoint = CGPoint(x: 0,y: 1)
          localView.layer.insertSublayer(gradient, atIndex: 0)
          localView.layer.masksToBounds = true
      }
  }
  </code></pre>
  
  <p>and applying via below code in UIViewController's viewDidLoad.</p>
  
  <pre><code>Constants.applyGradient(viewContactDetail, color1: gradientColor1, color2: gradientColor2)
  Constants.applyGradient(viewDiscountDetail, color1: gradientColor1, color2: gradientColor2)
  Constants.applyGradient(viewTermsCondDetail, color1: gradientColor1, color2: gradientColor2)
  Constants.applyGradient(viewDiscountAvailDetail, color1: gradientColor1, color2: gradientColor2)
  </code></pre>
  
  <p>And here is the result what I'm getting</p>
  
  <p><a href="https://i.stack.imgur.com/eHT4F.png" rel="nofollow"><img src="https://i.stack.imgur.com/eHT4F.png" alt="enter image description here"></a></p>
  
  <p>You can see, Gradient isn't apply on specific view properly.
  <br/>I'm not getting what is wrong with my code.</p>
  
  <p><strong>EDIT:</strong>
  Here is the hierarchical view.<br/>
  <a href="https://i.stack.imgur.com/NXg6H.png" rel="nofollow"><img src="https://i.stack.imgur.com/NXg6H.png" alt="enter image description here"></a> </p>