@implementation AVSuperView
- (AVSuperView*)initWithFrame:(CGRect)frame{
if (self = [super initWithFrame:frame]) {
// self.backgroundColor = [UIColor redColor];
self.layer.backgroundColor = [[UIColor redColor] CGColor];
AVLayout* avLayout = [[AVLayout alloc] init];
In a custom UIView, e.g. above, it seems the self.backgroundColor and self.layer.backgroundColor is the same. Is self.backgroundColor a wrapper for self.layer.backgroundColor?
Is
self.backgroundColora wrapper forself.layer.backgroundColor?
Yes, that is exactly what it is. The same is true of frame, of alpha and opacity, and various other properties (not to mention the fact that the drawing in the view is actually the drawing in the layer).
A view and its underlying layer are very initimately bound up. In a sense, the view exists only to endow the layer with the ability to receive touches.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With