I am writing a UI library in which i would like to be able to have the alpha of the UIViews as if the UIViewGroupOpacity info.plist ket was set. See following links:
Make UIView and subviews translucent as one layer, not individually
iOS controlling UIView alpha behaviour for subviews
But, as I am writing a lib, I dont want the projects to have to set this global key, and effect the behaviour of the main project.
Is there any other way of achieving this? I dont want to cycle through all the subviews and set alpha of each subview, as the project that includes my lib might have this key enabled…
Yes there is, you can set
shouldRasterizeof the view’s layer.This will have the same effect as
UIViewGroupOpacitybut only forcontainerViewand it’s subviews.