如何在翻转动画的中途更改 UIImageView 的图像。我的代码似乎确实翻转了 UIImageView 并成功更改了图像,但它正在瞬间改变。我想要实现的是仅在 180 度翻转达到 90 度翻转后才更改图像。这是我的代码:
在视图上创建 UIImageView:
UIImage *image = [UIImage imageNamed:@"fb1.jpg"];
imageView = [[UIImageView alloc] initWithImage:image];
vw = [[UIView alloc] initWithFrame:CGRectMake(20, 20, 80, 80)];
vw.layer.cornerRadius = vw.frame.size.width / 2;
imageView.frame = CGRectMake(20, 20, 80, 80);
imageView.layer.cornerRadius = imageView.frame.size.width / 2;
imageView.layer.masksToBounds = YES;
imageView.layer.borderColor = [[UIColor blackColor] CGColor];
imageView.layer.borderWidth = 1.0;
[self.view addSubview: imageView];
//[self.view addSubview:vw];
[imageView setUserInteractionEnabled:YES];
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(taptap:)];
[imageView addGestureRecognizer:tap];
点击动画 UIImageView:
[UIView animateWithDuration:2.0 delay:0.0 options:UIViewAnimationOptionCurveEaseInOut
animations:^(void) {
imageView.transform = CGAffineTransformMakeScale(-1, 1);
[UIView animateWithDuration:1.0 delay:1.0 options:UIViewAnimationOptionTransitionCrossDissolve
animations:^(void) {
imageView.image = [UIImage imageNamed:@"fb2.jpg"];
} completion:^(BOOL finished) {
}];
}
completion:^(BOOL finished) {
}];
此外,我正在特定 UIImageView 上的点击手势上制作此动画。