gpt4 book ai didi

ios - CADisplayLink iOS有什么用

转载 作者:可可西里 更新时间:2023-11-01 05:40:24 27 4
gpt4 key购买 nike

什么时候使用iOS quartz核心框架的CADisplayLink。 NSTimer 和 CADisplayLink 是一样的吗?什么是正确使用 CADisplayLink?我们要同步ios uiview的绘图

最佳答案

无耻地复制/粘贴the official documentation :

A CADisplayLink object is a timer object that allows your application to synchronize its drawing to the refresh rate of the display.

Your application creates a new display link, providing a target object and a selector to be called when the screen is updated. Next, your application adds the display link to a run loop.

Once the display link is associated with a run loop, the selector on the target is called when the screen’s contents need to be updated. The target can read the display link’s timestamp property to retrieve the time that the previous frame was displayed. For example, an application that displays movies might use the timestamp to calculate which video frame will be displayed next. An application that performs its own animations might use the timestamp to determine where and how displayed objects appear in the upcoming frame. The duration property provides the amount of time between frames. You can use this value in your application to calculate the frame rate of the display, the approximate time that the next frame will be displayed, and to adjust the drawing behavior so that the next frame is prepared in time to be displayed.

Your application can disable notifications by setting the paused property to YES. Also, if your application cannot provide frames in the time provided, you may want to choose a slower frame rate. An application with a slower but consistent frame rate appears smoother to the user than an application that skips frames. You can increase the time between frames (and decrease the apparent frame rate) by changing the frameInterval property.

When your application finishes with a display link, it should call invalidate to remove it from all run loops and to disassociate it from the target.

CADisplayLink should not be subclassed.

关于ios - CADisplayLink iOS有什么用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36640154/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com