开发者

Two questions about CALayer

开发者 https://www.devze.com 2023-04-10 03:12 出处:网络
with [myLayer setName:@\"layer_1\"] I set the name of a layer. But how can I get it from another method? Is there s开发者_如何学Goomething like [self.view.layer.sublayers getLayerByName:@\"layer_1\"]
  • with [myLayer setName:@"layer_1"] I set the name of a layer. But how can I get it from another method? Is there s开发者_如何学Goomething like [self.view.layer.sublayers getLayerByName:@"layer_1"]?
  • how to animate a CALayer to move it to another position with a nice smooth effect?


The name property is primarily intended for use by some layout managers, except layout managers don't exist on iOS, so all it's really useful for at this point is debugging.

As for animation, if you're using a CALayer you created yourself, you'll get implicit animations when you change properties. You can set explicit animations using the CAAnimation subclasses, and you can also tweak some parameters of the implicit ones with CATransaction.

If you're using a layer that's associated with a UIView, all implicit animations are disabled. You can still create explicit ones with the CAAnimation subclasses, or you can use the UIView animation methods.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号