`self.backgroundcolor` 和 `self.layer.backgroundcolor` 有什么区别?
Any difference between `self.backgroundcolor` and `self.layer.backgroundcolor`?
@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];
在自定义 UIView 中,例如上面的 self.backgroundColor
和 self.layer.backgroundColor
似乎是一样的。 self.backgroundColor
是 self.layer.backgroundColor
的包装器吗?
Is self.backgroundColor
a wrapper for self.layer.backgroundColor
?
是的,确实如此。 frame
、alpha
和 opacity
以及其他各种属性也是如此(更不用说视图中的绘图实际上是层中的绘图)。
视图和它的底层是非常紧密地联系在一起的。从某种意义上说,view的存在只是为了赋予layer接收触摸的能力。
@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];
在自定义 UIView 中,例如上面的 self.backgroundColor
和 self.layer.backgroundColor
似乎是一样的。 self.backgroundColor
是 self.layer.backgroundColor
的包装器吗?
Is
self.backgroundColor
a wrapper forself.layer.backgroundColor
?
是的,确实如此。 frame
、alpha
和 opacity
以及其他各种属性也是如此(更不用说视图中的绘图实际上是层中的绘图)。
视图和它的底层是非常紧密地联系在一起的。从某种意义上说,view的存在只是为了赋予layer接收触摸的能力。