ios-picker-dialog icon indicating copy to clipboard operation
ios-picker-dialog copied to clipboard

Possibly missing UIColor extension

Open FlyingCowMooMoo opened this issue 8 years ago • 1 comments

Hey,

Thank you for creating this utility, it's quite neat.

I encountered an error while trying it out.

In your file, you have made use of the UIColor with the following constructor UIColor(hex: intValueHere)

However that is not a valid overload(it's not in UIKit), so I assume you where using some kind of extension. I managed to patch it up for my use by adding the following extension.

extension UIColor {
    convenience init(hex: Int, alpha: Float = 1.0){
        let r = Float((hex >> 16) & 0xFF)
        let g = Float((hex >> 8) & 0xFF)
        let b = Float((hex) & 0xFF)

        self.init(red: CGFloat(r / 255.0), green: CGFloat(g / 255.0), blue:CGFloat(b / 255.0), alpha: CGFloat(alpha))
    }

}

I am doing something wrong and xcode was throwing erros on the original code? I am new to the whole OSX/iOS ecosystem, so I am not quite familiar with the standard libraries

FlyingCowMooMoo avatar May 15 '16 07:05 FlyingCowMooMoo

Hey @PeteShag - I'm not sure how I missed this notification.. but yes, you're right! I did accidentally include the hex extension in this project, nothing wrong on your part.

aguynamedloren avatar Aug 19 '16 07:08 aguynamedloren