Simulator
→ Debug
→ Color Off - Screen Rendered
這個勾選之后, 觸發離屏渲染的layer, 顏色會發生改變. 勾選取消都需要重新運行才生效
位置展示
例如:
UIView *bv = [[UIView alloc] initWithFrame:CGRectMake(50, 100, 300, 300)];
bv.backgroundColor = UIColor.blackColor;
[self.view addSubview: bv];
self.bv = bv;
UIView *v1 = [[UIView alloc] initWithFrame:CGRectMake(50, 50, 100, 100)];
v1.backgroundColor = UIColor.redColor;
v1.layer.shouldRasterize = YES;
[bv addSubview: v1];
UIView *v2 = [[UIView alloc] initWithFrame:CGRectMake(150, 150, 100, 100)];
v2.backgroundColor = UIColor.yellowColor;
[bv addSubview: v2];
UIView *v3 = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 50, 50)];
v3.backgroundColor = UIColor.brownColor;
[bv addSubview: v3];
其中 v1 背景紅色, 加個光柵化, v1.layer.shouldRasterize = YES; 會觸發離屏渲染
勾選前例子
勾選后, 可發現 v1會變成橙色
勾選后例子