I am creating a UILabel
that will have a gradient background color. The only problem is I am getting an error message saying the following:
"Cannot covert value of type Int
to expected argument type CGGradientDrawingOptions"
I am wondering if this is because of a simple syntax error or if I need to add or delete something from my code. Please inform me on what I need to add, delete, or fix in your answer and what the error means. Here is all the code:
import UIKit
@IBDesignable class PHLabel: UILabel {
@IBInspectable var startColor: UIColor = UIColor.greenColor()
@IBInspectable var endColor: UIColor = UIColor.greenColor()
override func drawRect(rect: CGRect) {
let context = UIGraphicsGetCurrentContext()
let colors = [startColor.CGColor, endColor.CGColor]
let colorSpace = CGColorSpaceCreateDeviceRGB()
let colorLocations:[CGFloat] = [0.0, 1.0]
let gradient = CGGradientCreateWithColors(colorSpace, colors, colorLocations)
var startPoint = CGPoint.zero
var endPoint = CGPoint(x:0, y:self.bounds.height)
CGContextDrawLinearGradient(context, gradient, startPoint, endPoint, 0)
}
}
Any suggestions or input is greatly appreciated.
Thanks in advance.