iOS - Поворот слоя вправо и влево с помощью двух разных кнопок UIB
Я создал слой с помощью CALayer и анимировал его с помощью CABasicanimation с анимацией поворота и создал две кнопки TouchDown UIB для поворота влево и вправо. У меня возникла проблема, когда слой поворачивается вправо, он возвращается к исходному углу и то же самое с левым вращением
Вот мой код:
-(void)viewDidLoad
{
//Button 1
UIButton *aButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
aButton.frame = CGRectMake(0, 0, 145, 145);
aButton.center = CGPointMake(90, 190);
aButton.backgroundColor = [UIColor redColor];
[aButton addTarget:self action:@selector(holdDown) forControlEvents:UIControlEventTouchDown];
[aButton addTarget:self action:@selector(holdRelease) forControlEvents:UIControlEventTouchUpOutside];
[aButton addTarget:self action:@selector(holdRelease) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:aButton];
//Button 2
UIButton *bButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
bButton.frame = CGRectMake(0, 0, 145, 145);
bButton.center = CGPointMake(690, 190);
bButton.backgroundColor = [UIColor redColor];
[bButton addTarget:self action:@selector(holddDown) forControlEvents:UIControlEventTouchDown];
[bButton addTarget:self action:@selector(holdReleasee) forControlEvents:UIControlEventTouchUpOutside];
[bButton addTarget:self action:@selector(holdReleasee) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:bButton];
}
-(void)holddDown{
animaEQ = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
animaEQ.toValue = [NSNumber numberWithFloat:5];
animaEQ.removedOnCompletion = NO;
animaEQ.repeatCount= HUGE_VAL;
animaEQ.duration = 2.2f;
[equaMi addAnimation:animaEQ forKey:@"blls"];
}
-(void)holdReleasee{
[equaMi removeAnimationForKey:@"blls"];
}
- (void)holdDown
{
animaEQl = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
animaEQl.toValue = [NSNumber numberWithFloat:-5];
animaEQl.removedOnCompletion = NO;
animaEQl.repeatCount= HUGE_VAL;
animaEQl.duration = 2.2f;
[equaMi addAnimation:animaEQl forKey:@"bls"];
}
- (void)holdRelease
{
[equaMi removeAnimationForKey:@"bls"];
}
Любая помощь, пожалуйста?
Заранее спасибо