Search code examples
iosobjective-cswiftuiviewcalayer

Best way to handle many sub UI elements in a UIView


I have a UIView that should be contained many different circular elements (as subview or sublayer). Circular elements are just small shapes that are just filled circle with capability of taping on them and doing some actions. I can add them to the view as CAShapeLayer or UIView, but I have no idea which approach is better in terms of performance.

The elements should be animated when they are going to appear at the first time! afterwards they should recognize the tap gesture on them. Both UIView and CAShapeLayer or CALayer objects are capable of animation, but considering the count of these elements (which could be up to 30 items) and concurrence of animations, which approach do you suggest considering performance and reliability issue?

I've searched around a lot but the information was not enough to be able to make a certain decision.

Thanks in advance


Solution

  • You are fine with UIViews. For the tap gestures you will need them. There should not be any significant performance differences (if any) between the two approaches.