Using the Objective-C Runtime, how do I add the method +layerClass to the private UIGroupTableViewCellBackground class (not to its superclass, UIView)? Note: This is only for testing (to see how UITableViewStyleGrouped sets cell backgroundView & selectedBackgroundView).
Using the Objective-C Runtime, how do I add the method +layerClass to the private
Share
To dynamically add a class method, instead of an instance method, use
object_getClass(cls)to get the meta class and then add the method to the meta class. E.g.:You might also be able to do this easier by adding the
+layerClassmethod to a category ofUIGroupTableViewCellBackgroundand using a forward class definition, i.e.@class UIGroupTableViewCellBackground, to get it to compile.