iOS版:我要补充UIViews或CALayers动画? [英] iOS: Should I Add UIViews or CALayers for animation?

查看:96
本文介绍了iOS版:我要补充UIViews或CALayers动画?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

比方说,我想50图像添加为他们制作动画的目的视图。让我们假设我打算使用的Core Animation(例如,CABasicAnimation),而不是UIView的动画。

Let's say I want to add 50 images to a view for the purpose of animating them. And let's suppose I'm planning on using Core Animation (e.g., CABasicAnimation) rather than "UIView" animation.

我是不是最好加入50子视图或50子层实现这一点?是否有所作为?

Am I better off implementing this by adding 50 subviews or 50 sublayers? Does it make a difference?

感谢。

推荐答案

当我描述<一个href=\"http://stackoverflow.com/questions/1447598/when-to-use-calayer-on-the-mac-iphone/1449201#1449201\">here,我用的动画都UIViews和CALayers,发现它们之间存在微小的性能差异。 UIViews都是层周围非常轻便的包装。另外,你需要任何基于层的动画可以很容易地应用到一个UIView的衬里层。

As I describe here, I've used both UIViews and CALayers in animations and found a negligible performance difference between them. UIViews are very lightweight wrappers around the layers. Also, any layer-based animations you need can be applied to a UIView's backing layer easily.

我直接使用CALayers在我想创建跨平台(苹果/ iOS版)的UI元素的情况下,因为CALayers是在他们两个平台(不像显著不同NSViews和UIViews)实施几乎相同。 CALayers没有任何接触处理例程开箱,但如果需要,您可以添加该功能。

I've used CALayers directly in situations where I wanted to create cross-platform (Mac / iOS) UI elements, because CALayers are almost identical in their implementation on both platforms (unlike the significantly different NSViews and UIViews). CALayers don't have any touch-handling routines out of the box, but you can add that capability if you need to.

也有一些优势情况下,你可能希望直接与层工作,当试图做层的有限的3-D操作(如在的CoverFlow效果)或使用CAReplicatorLayer产生粒子特效时等。

There are also some edge cases where you might want to work directly with layers, like when trying to do limited 3-D manipulation of the layers (as in a CoverFlow effect) or when using a CAReplicatorLayer to produce particle effects.

这篇关于iOS版:我要补充UIViews或CALayers动画?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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