iOS 模拟器查看离屏渲染

2024-03-02  本文已影响0人  ShawnAlex

SimulatorDebugColor 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会变成橙色


勾选后例子
上一篇 下一篇

猜你喜欢

热点阅读