我尝试在动画完成中设置背景图像,基本上它可以防止动画发生。这是动画的代码:
[UIView animateWithDuration: 0.5f animations: ^
{
//[buttonPanel setBackgroundImage: [UIImage imageNamed: imageName] forState: UIControlStateNormal];
CGFloat yOrigin = buttonFrame.origin.y - (self.bounds.size.height - buttonFrame.size.height);
yOrigin -= buttonFrame.size.height;
buttonPanel.frame = CGRectMake(buttonFrame.origin.x, yOrigin, buttonFrame.size.width, buttonFrame.size.height);
}
completion: ^(BOOL finished)
{
[UIView animateWithDuration: 0.5f animations:^
{
[buttonPanel setBackgroundImage: [UIImage imageNamed: imageName] forState: UIControlStateNormal];
[self setAlpha: 1.0f];
}];
}];
如果我删除 setBackgroundImage: 消息,它只会正确地动画到新的帧位置。为什么?
谢谢你。