If I have two UIColors, what\'s the best way to draw an even gradient between them over an arbitrarily-sized area?
I am guessing you would create a UIView subclass a
The Swift way to add Gradient is :
var view : UIView = UIView(frame: CGRectMake(0, 0, 320, 100))
var g : CAGradientLayer = CAGradientLayer()
g.frame = gradientView.bounds
g.colors = ["000000".UIColor.CGColor , "111111".UIColor.CGColor]
view.layer.insertSublayer(g, atIndex: 0)
UIColor()
is a helper class for Swift to convert hex color
to rgb color
, highly recommended.