アニメーションでボタンを移動します。UIVIewController 内で使用するとすべて完全に機能します。このアニメーションで UIView をサブクラス化しようとすると、ボタンがエンドポイントに表示されますが、表示されません。動いています。間違いはどこですか?
これは私のコードです:
- (void) moveButton:(UIButton *)button fromPoint:(CGPoint)startPoint toPoint:(CGPoint)endPoint {
CGMutablePathRef thePath = CGPathCreateMutable();
CGPathMoveToPoint(thePath, NULL, startPoint.x, startPoint.y);
NSMutableArray *timings = [NSMutableArray array];
NSMutableArray *keytimes = [NSMutableArray array];
// Start
[timings addObject:[self getTiming:kCAMediaTimingFunctionEaseIn]];
[keytimes addObject:[NSNumber numberWithFloat:0.0]];
// Bounce
[timings addObject:[self getTiming:kCAMediaTimingFunctionEaseIn]];
[keytimes addObject:[NSNumber numberWithFloat:1.0]];
CAKeyframeAnimation * animation;
animation = [CAKeyframeAnimation animationWithKeyPath:@"position"];
animation.fillMode = kCAFillModeForwards;
animation.removedOnCompletion = NO;
animation.duration = 2;
animation.path = thePath;
animation.timingFunctions = timings;
animation.keyTimes = keytimes;
[[button layer] addAnimation:animation forKey:nil];
[[button layer] setPosition:CGPointMake(endPoint.x,endPoint.y)];
}