アニメーションを開始する機能があります。三角形は「drawrect」で設計されており、コントローラーにボタンがあり、押すと「startTriangleAnimation」と呼ばれます。
問題は、メソッド「startTriagnleAnimation」がアニメーションを追加していないことです。NSLOGを出力するので、プログラムはこのメソッドに入ると確信しています。
誰もが行う方法を知っていますか?
- (void)startTriangleAnimation
{
[self setNeedsDisplay];
if (_leftFoot) {
NSLog(@"LEFT FOOT ANIMATION STARTING");
[UIView animateWithDuration:15
delay:0
options: UIViewAnimationOptionCurveLinear
animations:^{
self.transform = CGAffineTransformMakeRotation(DEGREES_TO_RADIANS(-FIRST_ROTATION));
} completion:^(BOOL finished) {
[UIView animateWithDuration:15
delay:0.5
options: UIViewAnimationOptionCurveLinear
animations:^{
self.transform = CGAffineTransformRotate(self.transform, DEGREES_TO_RADIANS(-SECOND_ROTATION));
} completion:^(BOOL finished) {
[UIView animateWithDuration:15
delay:0.5
options: UIViewAnimationOptionCurveLinear
animations:^{
self.transform = CGAffineTransformRotate(self.transform, DEGREES_TO_RADIANS(-THIRD_ROTATION));
}completion:^(BOOL finished) {
[UIView animateWithDuration:15
animations:^{
self.transform = CGAffineTransformRotate(self.transform, DEGREES_TO_RADIANS(-FOURTH_ROTATION));
}];
}];
}];
}];
} else {
NSLog(@"RIGHT FOOT ANIMATION STARTING");
[UIView animateWithDuration:15
delay:0
options: UIViewAnimationOptionCurveLinear | UIViewAnimationOptionBeginFromCurrentState
animations:^{
NSLog(@"animating");
self.transform = CGAffineTransformMakeRotation(DEGREES_TO_RADIANS(FIRST_ROTATION));
} completion:^(BOOL finished) {
[UIView animateWithDuration:15
delay:0.5
options: UIViewAnimationOptionCurveLinear | UIViewAnimationOptionBeginFromCurrentState
animations:^{
self.transform = CGAffineTransformRotate(self.transform, DEGREES_TO_RADIANS(SECOND_ROTATION));
} completion:^(BOOL finished) {
[UIView animateWithDuration:15
delay:0.5
options: UIViewAnimationOptionCurveLinear | UIViewAnimationOptionBeginFromCurrentState
animations:^{
self.transform = CGAffineTransformRotate(self.transform, DEGREES_TO_RADIANS(THIRD_ROTATION));
}completion:^(BOOL finished) {
[UIView animateWithDuration:15
animations:^{
self.transform = CGAffineTransformRotate(self.transform, DEGREES_TO_RADIANS(FOURTH_ROTATION));
}];
}];
}];
}];
}
}
- (void)drawRect:(CGRect)rect
{
CGFloat x = self.bounds.size.height;
CGFloat y = self.bounds.size.width;
[[UIColor redColor] setStroke];
UIBezierPath *path = [UIBezierPath bezierPath];
[path moveToPoint:CGPointMake(x/2, y - 20)];
[path addLineToPoint:CGPointMake(x/2 - 10, y)];
[path addLineToPoint:CGPointMake(x/2 + 10, y)];
[path closePath];
[path fill];
//[path stroke];
if (_leftFoot) {
self.transform = CGAffineTransformMakeRotation(DEGREES_TO_RADIANS(10));
} else {
self.transform = CGAffineTransformMakeRotation(DEGREES_TO_RADIANS(-10));
}
}