我正在尝试使用 CGAffineTransformMakeScale 为自定义按钮设置动画,如下所示:
if (stateButton == 0) { //The button is gonna appear
self.selected = YES;
self.imageView.transform = CGAffineTransformMakeScale(0.01, 0.01);
[UIView animateWithDuration:0.5 delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{
// animate it to the identity transform (100% scale)
self.imageView.transform = CGAffineTransformIdentity;
} completion:nil];
}
else if (stateButton ==1) { //The button is gonna disappear
self.imageView.transform = CGAffineTransformMakeScale(1, 1);
[UIView animateWithDuration:0.5 delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{
// decrease button
self.imageView.transform = CGAffineTransformMakeScale(.01, .01);
} completion:^(BOOL finished){
self.selected = NO;
}];
}
按钮完美地增长到原始大小,但是,我不知道原因,但是当我单击按钮减小它时,它会从比原始大小大 100% 的大小减小到原始大小,而不是开始正如我在代码中指出的那样,原始大小的减小并达到 0.01 的比例。
请帮忙!!