Pregunta

i am trying to learn iOS developing, but i using + (UIColor *)colorWithRed:(CGFloat)red green:(CGFloat)green blue:(CGFloat)blue alpha:(CGFloat)alpha

I always not getting the right number, it always like something missing..

Please help..

here is my code:

[UIColor colorWithRed:65/255 green:62/255 blue:125/255 alpha:1.0];
¿Fue útil?

Solución

easy...

you simply need to add .0 at the end of each number, like this:

[UIColor colorWithRed:65.0/255.0 green:62.0/255.0 blue:125.0/255.0 alpha:1.0];

since they need Float value instead of int.

Otros consejos

Use this and add .0f after each parameter

[UIColor colorWithRed:65.0f/255.0f green:62.0f/255.0f blue:125.0f/255.0f alpha:1.0f];
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top