Yes, each UIView
has an underlying CALayer
which is added to its superview's layer when the view is added to the superview.
I don't know the ideal way to find only your own layers. Since sublayers
is an NSArray
(as opposed to an NSSet
), it means it's an ordered list, which means you can be sure that the order in which you add views to the superview is the same order they will appear in said array.
Thus, if you add your UIViews first, and then add your own drawn CALayers afterwards, you can probably get your own by accessing the objects starting at index 2 (skipping 0 and 1) in sublayers
.
Of course, if you then add or remove views to the superview you'd have to modify this value, so presuming this actually works, you'll want to somehow dynamically generate it.
You can ascertain the index for a layer as you add it, using indexOfObject:
on the sublayers
property. A safer route might be to simply store this index somewhere in a list and to access the sublayers with indices from that list only.