默认情况下,CABasicAnimation是否在主线程或后台线程中运行

默认情况下,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.