因此,UIButton的动画大小转换似乎存在问题 . 具体来说,如果你有一个UIButtonTypeCustom类型的按钮,任何帧大小转换都会立即发生 . 运动和其他动画正常发生 .
有没有人对此有一个很好的解决方案?我猜这是因为自定义按钮包含图像,当UIView计算其变换时出现问题 .
This guy似乎找到了同样的问题,但没有解决方法 .
这是一个例子 . 图像原点将在两秒内从0.0,0.0平滑移动到100.0,100.0,但尺寸会立即跳到200x200 .
UIButton *tButton = [UIButton buttonWithType:UIButtonTypeCustom];
[tButton setBackgroundImage:tImage forState:UIControlStateNormal];
tButton.frame = CGRectMake(0.0, 0.0, 10.0, 10.0);
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationDuration:2.0];
tButton.frame = CGRectMake(100.0, 100.0, 200.0, 200.0);
[UIView commitAnimations];
1 回答
感谢davbryn获得此答案,但不是重新定义您使用的框架:
它不像使用新框架那么容易,所以你必须玩它,但它应该让你指向正确的方向 .