默认情况下,CABasicAnimation是否在主线程或后台线程中运行 [英] Does CABasicAnimation runs in the main or background thread by default

查看:201
本文介绍了默认情况下,CABasicAnimation是否在主线程或后台线程中运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这比编码更像一个概念查询.我有一个自定义活动指示器,一个自定义视图.用户将拥有的唯一公共API是init(onFrame frame: CGRect)startAnimating()stopAnimating().

This is more a conceptual query than coding. I have a custom activity indicator, a custom view. The only public API, the user will have is the init(onFrame frame: CGRect), startAnimating() and stopAnimating().

所以,我想在startAnimating方法中知道是否应该创建一个线程(无论是main还是DispatchQoS)来运行动画.

So, I want to know in the startAnimating method, should I create a thread whether main or DispatchQoS to run the animation.

此外,如果我不将动画代码放入线程中,它将自动在主线程上运行吗?

Also, if I don't put the animation code in a thread, will it be automatically running on main thread?

推荐答案

与UIView的所有通信都必须在主线程上.所有Core Animation都会在后台线程上自动执行.因此,请不要与CABasicAnimation关联任何显式的多线程.

All communication with a UIView must be on the main thread. All Core Animation is automatically performed on a background thread. So do not do any explicit multithreading in connection with CABasicAnimation.

这篇关于默认情况下,CABasicAnimation是否在主线程或后台线程中运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆