It would be helpful to attach the relevant code snippets where you are working with colors and applying them to a
UIImageView
when posting a your question
However i think your are facing a color space conversion issue from your description when trying to apply a picked color . You can convert the color to the desired color space before applying it to the tintColor
. You can make an extension to convert the color to the desired color space:
import UIKit
extension UIColor {
func convertToSRGB() -> UIColor? {
guard let ciColor = self.cgColor.converted(to: CGColorSpace(name: CGColorSpace.sRGB), intent: .defaultIntent, options: nil) else {
return nil
}
return UIColor(cgColor: ciColor)
}
}
// usage
let pickedColor: UIColor = // color picked from UIColorPickerViewController
if let sRGBColor = pickedColor.convertToSRGB() {
imageView.tintColor = sRGBColor
}
Above extension method convertToSRGB
attempts to convert the color to the sRGB color space. You can then set the converted color as the tintColor
for your UIImageView
.
Note: color space conversions can sometimes lead to subtle changes in appearance, especially if the original color was outside the sRGB color space