无法在Swift中找到'/'的重载

时间:2014-08-02 12:55:20

标签: ios swift operator-overloading var

无法找到' /'接受以下语句提供的参数。

class func getColor(hexColor:NSString) -> UIColor
{
    var red, green, blue:CUnsignedInt
    var range : NSRange
    range.length = 2
    range.location = 0
    NSScanner.scannerWithString(hexColor.substringWithRange(range)).scanHexInt(&red)
    range.location = 2
    NSScanner.scannerWithString(hexColor.substringWithRange(range)).scanHexInt(&green)
    range.location = 4
    NSScanner.scannerWithString(hexColor.substringWithRange(range)).scanHexInt(&blue)
    red = Float(red/255.0)
    green = Float(green/255.0)
    blue = Float(blue/255.0)
    return UIColor(red: red, green: green, blue: blue, alpha: 1.0)
    //return UIColor(red: Float(red/255.0), green: Float(green/255.0), blue: Float(blue/255.0), alpha: 1.0)
    //return UIColor.cyanColor()
}

出了什么问题? 如何在swift中使用除法(/)? 请帮帮我。

提前致谢。

0 个答案:

没有答案