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
Post a Comment