self.backgroundcolor和self.layer.backgroundcolor之间有什么区别吗?

Jic*_*hao 1 cocoa-touch core-animation ios

@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];
Run Code Online (Sandbox Code Playgroud)

在上面的自定义UIView中,例如self.backgroundColor和似乎self.layer.backgroundColor相同。是self.backgroundColor包装纸self.layer.backgroundColor吗?

mat*_*att 5

self.backgroundColor包装纸self.layer.backgroundColor吗?

是的,这就是事实。同样是真实的frame,的alphaopacity,以及其他各种特性(更不用说的是,在该视图的图实际上是在层中的图)。

视图及其底层是非常初始的绑定。从某种意义上说,该视图仅存在于赋予图层接收触摸的能力。