Complementry color for any color iOS swift

 Solution:


You can use this extension for getting the complementary colour for any colours in iOS swift.

extension UIColor {

var compColor: UIColor {
        
        let ciColor = CIColor(color: self)
        
        let compRed: CGFloat = 1.0 - ciColor.red
        let compGreen: CGFloat = 1.0 - ciColor.green
        let compBlue: CGFloat = 1.0 - ciColor.blue
        
        return UIColor(red: compRed, green: compGreen, blue: compBlue, alpha: ciColor.alpha)
    }

}


Comments

Popular posts from this blog

Invalid bundle error while upload the app to the app Store

Saved Image in document directory and save path in coredata not able to fetch the image file iOS swift