Draw a UIView in greyscale?
filter, grayscale, ios, uiview
Solution
Add a CALayer to your UIView, with the compositingFilter set to colorBlendMode:
let grayLayer = CALayer()
grayLayer.frame = bounds
grayLayer.compositingFilter = "colorBlendMode"
grayLayer.backgroundColor = UIColor(red: 0.2, green: 0.2, blue: 0.2, alpha: 1.0).cgColor
layer.addSublayer(grayLayer)
Problem
Is there a way to draw a given UIView (and it's subviews) in greyscale? I'm trying to take a view hierarchy and make it look disabled without overlaying an image or switching the images used to draw each UIView in the hierarchy.