我正在尝试使用 zPosition 将这个 CATextLayer 放在我的 CALayer 之上,但是 CATextLayer 似乎总是在 CALayer 后面?
CALayer *sublayer = [CALayer layer];
sublayer.backgroundColor = [UIColor colorWithRed:0/255.0 green:156.0/255.0 blue:222.0/255.0 alpha:1.0].CGColor;
sublayer.shadowOffset = CGSizeMake(0, 3);
sublayer.shadowRadius = 5.0;
sublayer.shadowColor = [UIColor blackColor].CGColor;
sublayer.shadowOpacity = 0.8;
sublayer.frame = CGRectMake(340, 435, 126, 1);
sublayer.zPosition=1;
[self.view.layer addSublayer:sublayer];
CGSize size=CGSizeMake(126, 265);
[self resizeLayer:sublayer to:size];
CATextLayer *label = [[CATextLayer alloc] init];
[label setFont:@"Helvetica-Neue"];
[label setFontSize:56];
[label setFrame: self.view.frame];
[label setString:@"56"];
[label setAlignmentMode:kCAAlignmentCenter];
[label setForegroundColor:[[UIColor whiteColor] CGColor]];
label.zPosition=99;
[self.view.layer addSublayer:label];