objective c - How can I subclass CALayer to return a pre-styled layer? -
How do you subclass the CALayer so you can return a layer with styling properties already set?
:
MyCustomLayer * layer = [MyCustomLayer layer]; will create a layer with these properties;
Layer. Background Color = sweetBackgroundColor.CGColor; Layer. Border Coral = sweetBorderColor.CGColor; Layer.borderWidth = 2.0; Layer cornerradia = 8.0; so that I can just set its frame and add it to the tree.
But I think that my question can really be, how can you create an object that it already has the properties established on creation. possible?
Just override -init (named initializer for caller) in your subclass, and set those properties In your override, any creation method, in which - the layer should be routed through the designated initial medium, which means that your additional setup will be also for the facilitator.
Comments
Post a Comment