1

我想用这种方法在两个视图控制器之间创建一个转换:

-(void)animate {

    UIImage *maskingImage = [UIImage imageNamed:@"mask.png"];
    CALayer *maskLayer =[CALayer layer];
    maskLayer.anchorPoint=CGPointMake(0.5, 0.5);
    maskLayer.frame=self.view.superview.frame;
    maskLayer.contents=(id)self.maskingImage.CGImage;
    self.view.layer.mask=maskLayer;

    CABasicAnimation* anim = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
    anim.duration = 2.5;
    anim.toValue=[NSNumber numberWithInt:self.view.bounds.size.height/8];
    anim.fillMode=kCAFillModeBoth;
    anim.removedOnCompletion=NO;
    anim.delegate = self;
    [self.view.layer.mask addAnimation:anim forKey:nil];
}

我的错误在哪里?我已经尝试过像这样的其他过渡并且它有效:

-(void)animate {

    CABasicAnimation* anim = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
    anim.toValue = [NSNumber numberWithDouble:0.9];
    anim.duration = 0.5;
    anim.delegate = self;
    [self.view.layer addAnimation:anim forKey:nil];
}

mask.png 是一个带有中心白色圆圈的黑色矩形

4

0 回答 0