     }
 
     open override func awakeFromNib() {
-        self.gradientLayer.colors = self.colors
+        self.refresh()
     }
 
     open override func layoutSubviews() {
         super.layoutSubviews()
+
+        self.refresh()
 
         self.gradientLayer.startPoint = CGPoint(
             x: self.startXPercent,

open class CustomGradientView: UIView {
    @IBInspectable public var startXPercent: CGFloat = 0
    @IBInspectable public var startYPercent: CGFloat = 0
    @IBInspectable public var endXPercent: CGFloat = 0
    @IBInspectable public var endYPercent: CGFloat = 0

    @IBInspectable
    public var startColor: UIColor = UIColor.red {

        self.gradientLayer.add(animation, forKey: "animateColors")
    }
}

private extension CustomGradientView {
    func refresh()  {
        self.gradientLayer.colors = self.colors
    }
}
#endif
