このメソッドを使用して、2 つのビュー コントローラー間の遷移を作成したいと思います。
-(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 は、中央に白い円がある黒い長方形です。