Using CALayer Delegate

前端 未结 8 1109
滥情空心
滥情空心 2020-12-02 08:44

I have a UIView whose layers will have sublayers. I\'d like to assign delegates for each of those sublayers, so the delegate method can tell the layer what to draw. My que

8条回答
  •  执念已碎
    2020-12-02 09:17

    Take a look at the docs on formal vs informal protocols. The CALayer is implementing an informal protocol which means that you can set any object to be its delegate and it will determine if it can send messages to that delegate by checking the delegate for a particular selector (i.e. -respondsToSelector).

    I typically use my view controller as the delegate for the layer in question.

提交回复
热议问题