Question about CALayer and UIView

The challenge is to implement a translucent layer that would slip to collect the user's response when necessary. On the translucent layer, it will have some icons for the user. I am currently using a CALayer object that looks fine, and it has some assembly in the animation behavior.

But the problem is that CALayer does not respond at all to any touch events. Now I think that I should use UIView instead. UIView inherits from UIResponder, so its objects are naturally capable of responding to user events.

This is a solution between UIView and CALayer. I have done quite a lot of work for CALayer, and it looks quite normal, except that I need to add a touch response. Or should I use UIView as a subview instead (since it has a built-in touch response)?

Hope anyone knows about this, can help ...

+3
source share
1 answer

To respond to user interaction, the best way is to use UIView. Perhaps you can make it work without it, but I would not recommend it.

UIView, UIView +layerClass, Class CALayer. , CALayer (, , ), UIView -drawLayer:inContext:.

+5

All Articles