atomikpanda / libcolorpicker

Color Picker Library For iOS
MIT License
38 stars 18 forks source link

When i make my fallback Colour this it doesn't set the Colour to 0% alpha in my tweak preferences instead it sets it to 100% alpha #9

Open atebitsy-old opened 5 years ago

atebitsy-old commented 5 years ago

when i make my fallback Colour this it doesn't set the Colour to 0% alpha in my tweak preferences instead it sets it to 100% alpha #000000:0.00

CobreDev commented 4 years ago

Did you ever find a fix for this? I need to make the alpha 0.44, but I can't figure out how to.

brendonjkding commented 4 years ago

The reason is the alpha of fallback UIColor returned by colorFromHex is fixed at 1 https://github.com/atomikpanda/libcolorpicker/blob/3ff8e63e773fa251a4b4bc2b6cbf560661137209/libcolorpicker.mm#L125-L128 A workaround is to manually set default value like this

NSString *colorString = prefs?(prefs[@"bgColor"]?:@"#0027FF:0.2"):@"#0027FF:0.2"; 
UIColor *bgColor = LCPParseColorString(colorString, nil);