画像に「ブラインドダウン」効果を作成して、画像が「ブラインドダウン」して表示されるようにしたい。
このJavaScriptトランジションのようなもの: https ://github.com/madrobby/scriptaculous-http : //madrobby.github.io/scriptaculous/effect-blinddown/
マスクの位置を手動で変更すると、マスクの背後にある画像が非表示および表示されるため、マスクは正しく設定されていますが、アニメーション化されません。それは最終的にアニメートの最終位置になり、実際にブラインドになることはありません。
助けてください!たぶん、これはブラインドダウン効果を達成するための最良の方法ではありませんか?
// create a new layer
CALayer *numberLayer = [[CALayer alloc] init];
// render the number "7" on the layer
UIImage *image = [UIImage imageNamed:@"number-7.png"];
numberLayer.contents = (id) [image CGImage];
numberLayer.bounds = CGRectMake(0, 0, image.size.width, image.size.height); // width and height are 50
numberLayer.position = position;
// create a new mask that is 50x50 the size of the image
CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
CGMutablePathRef path = CGPathCreateMutable();
CGPathAddRect(path, nil, CGRectMake(0, 0, 50, 50));
[maskLayer setPath:path];
[maskLayer setFillColor:[[UIColor whiteColor] CGColor]];
[theLayer setMask:maskLayer];
[maskLayer setPosition:CGPointMake(0, 0)]; // place the mask over the image
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:3.0];
[maskLayer setPosition:CGPointMake(0, 50)]; // slide mask off the image
// this should shift the blind away in an animation
// but it doesn't animate
[UIView commitAnimations];
[maskLayer release];
[boardLayer addSublayer:numberLayer];
[numberLayer release];