在iPhone中标记CALayers [英] Tagging CALayers in iPhone

查看:56
本文介绍了在iPhone中标记CALayers的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种通用方法,以便能够在层次结构中搜索唯一的CALayer,而不必记住该层在层次结构中的位置(并使用sublayer:和superlayer:方法)。

I am looking for a general way to be able to search for a unique CALayer in a hierarchy without having to remember where the layer is in a hierarchy (and use the sublayer: and superlayer: methods).

我知道UIViews可以做到这一点(这使得翻转视图变得容易),但是CALayer可以吗?

I know this is possible with UIViews (which makes flipping views easy) but is it possible for CALayer?

感谢您的帮助

皮曼

推荐答案

您也可以使用CALayer的name属性。

You can also use the name property of the CALayer.

[layer setName:@"myKey"];

要查找,

- (CALayer *)myLayer {

    for (CALayer *layer in [superLayerOfMyLayer sublayers]) {

            if ([[layer name] isEqualToString:LabelLayerName]) {
                return layer;
            }
    }

    return nil;
}

这篇关于在iPhone中标记CALayers的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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