I want to add the gradient as a background to label. I used the following code to acheive that. but the problem is that though the gradient color appears on the label, but t
One more additional think to correct answer. If you are use autolayouts for place your custom view you can get this problem - http://prntscr.com/5tj7bx
So your view has a different size then subView - UILabel and subLayer - gradient layer.
I solve this problem by add one method
class wResultView: UIView {
var label = UILabel()
var gradientLayer = CAGradientLayer()
override func layoutSubviews() {
gradientLayer.frame = self.bounds
label.frame = self.bounds
}
......