我有一个 UIPanGestureRecognizer。它工作正常。我做了一个 if 语句,所以当有人触摸图片时,它会是 alpha 0.7,并且会大 1.5 倍。alpha 工作正常,但是当我输入 CAAffineTransformMakeScale 方法时,我的图像不会移动。
这是我的代码:
- (IBAction)Bloemen:(UIPanGestureRecognizer *)recognizer {
CGPoint translation = [recognizer translationInView:self.view];
recognizer.view.center = CGPointMake(recognizer.view.center.x + translation.x,
recognizer.view.center.y + translation.y);
[recognizer setTranslation:CGPointMake(0, 0) inView:self.view];
if (UIGestureRecognizerStateBegan)
{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDelay:0.1];
[UIView setAnimationDuration:0.4];
bloemen.alpha = 0.7f;
bloemen.transform = CGAffineTransformMakeScale(1.5,1.5);
[UIView commitAnimations];
}
if (UIGestureRecognizerStateEnded) {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDelay:0.1];
[UIView setAnimationDuration:0.1];
bloemen.alpha = 1.0f;
bloemen.transform = CGAffineTransformIdentity;
[UIView commitAnimations];
}
}