How to synchronize OpenGL drawing with UIKit updates

前端 未结 6 550
深忆病人
深忆病人 2020-12-24 02:24

In our app we have UIScrollView above CAEAGLLayer. UIScrollView contains some UIViews (red rectangles). In CAEAGLLayer we draw white rectangles. Centers of white rectangles

6条回答
  •  南笙
    南笙 (楼主)
    2020-12-24 02:55

    In order to synchronize UIKit and OpenGL drawing, you should try to render where Core Animation expects you to draw, i.e. something like this:

    - (void)displayLayer:(CALayer *)layer
    {
        [self drawFrame];
    }
    
    - (void)updateVisibleRect:(CGRect)rect {
        _visibleRect = rect;
        [self.layer setNeedsDisplay];
    }
    

提交回复
热议问题