我有一個函數應該開始動畫。三角形設計爲「drawrect」,我在控制器中有一個按鈕,當它被按下時,它會調用「startTriangleAnimation」。動畫UIView調用metod
問題是方法「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));
}
}
這段代碼壓痕傷害了我的眼睛......和我的心臟 – 2013-03-25 18:04:33
這是xcode的身份 – Vannian 2013-03-25 18:09:27