hayashi311 / Color-Picker-for-iOS

Colorful: iOS color picker built with Swift.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Casting Hex Colors

pedro380085 opened this issue · comments

Casting your hex values on info view is loosing some precision, here is the updated method:

    CGFloat rFloat, gFloat, bFloat, aFloat;
    [self getRed:&rFloat green:&gFloat blue:&bFloat alpha:&aFloat];

    int r, g, b;
    r = (int)ceilf(255.0 * rFloat);
    g = (int)ceilf(255.0 * gFloat);
    b = (int)ceilf(255.0 * bFloat);

    return [NSString stringWithFormat:@"#%02x%02x%02x", r, g, b];