开发者

Cocoa Touch - Incompatible types in assignment

I am trying to convert hex color values into floats. I have a DataController class with a method like so:

+(float)floatFromHexColorInteger:(float)hexFloat {
    float newColorFloat = hexFloat / 255.0f;
    return newColorFloat;
}

I want to use it to easily get a color value between 0.0 and 1.0, so I can use it like so:

float colorFloat = [DataController floatFromHexColorInteger:79.0f];
//error on li开发者_如何学运维ne above is:
//Classes/RootViewController.m:53: error: incompatible types in assignment
self.navigationController.toolbar.tintColor = [UIColor colorWithRed:colorFloat green:colorFloat blue:colorFloat alpha:1.0f];

I'm getting a compiler error (2) on the first line, about incompatible types. Can anyone figure out why?


If +(float)floatFromHexColorInteger:(float)hexFloat is declared somewhere (in the .h file for example), you should check that the return type is float too.

If it's something else, the compiler may throw an error.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜