Ios 阿尔法掩模过渡
我想使用此方法在两个视图控制器之间创建转换:Ios 阿尔法掩模过渡,ios,view,controller,transition,mask,Ios,View,Controller,Transition,Mask,我想使用此方法在两个视图控制器之间创建转换: -(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; maskLa
-(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是一个以白色圆圈为中心的黑色矩形