gpt4 book ai didi

ios - 在 mask 层之上询问 CATextLayer

转载 作者:行者123 更新时间:2023-11-28 22:33:56 25 4
gpt4 key购买 nike

在我的应用程序中,我向 UIImageView 添加了一个 mask ,并将其设置为半不透明。此外,还有一个在该 CALayer 上运行的 CAAnimation。

现在,我想在上面添加一个 CATextLayer,它不能受到 mask 层的影响。我该怎么做?

谢谢

编辑:出现了一个新问题。不知何故,如果在 animationDidStart 中向 CATextLayer 发送消息,则动画将以相反的顺序执行。

- (void)viewDidLayoutSubviews {

for (int i=1; i<6; i++) {
NSString* intValue = [NSString stringWithFormat:@"%d", i];

CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"path"];

animation.duration = 0.5;

animation.delegate = self;

animation.repeatCount = 0;

animation.autoreverses = NO;

[animation setValue:intValue forKey:@"animationString"];

animation.timingFunction = nil;

[animation setRemovedOnCompletion:NO];

[animation setFillMode:kCAFillModeForwards];

animation.fromValue = (id) [self getCGRectForZoomLevel:i];

animation.toValue = (id) [self getCGRectForZoomLevel:i + 1 ];

animation.beginTime = CACurrentMediaTime() + i * 2;

[self.shapeLayer addAnimation:animation forKey:intwaarde];


}

最佳答案

您应该重新考虑您的层次结构。

添加一个 View 作为容器,将 ImageView 和文本层分组,使它们成为兄弟(与现在文本层是 ImageView 的子层相比)

然后像您已经在做的那样屏蔽 ImageView 。

Container   // ⬅ this one is new

┣━━ Image view ┅ (mask)

┗━━ Text layer // ⬅ is now a sibling

关于ios - 在 mask 层之上询问 CATextLayer,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16660444/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com