我有一个在 IB 中创建的按钮
有一段时间我在屏幕上输出这个按钮
然后当我点击它时,我隐藏它
[UIView animateWithDuration:0.2f
delay:0
options:UIViewAnimationOptionCurveEaseInOut
animations:^
{
self.checkYESButton.alpha = 0.0f;
}
completion:^(BOOL finished)
{
self.checkYESButton.hidden = YES;
}];
}
然后我想再次拍摄并更改图像,但没有任何反应
self.checkYESButton.hidden = NO;
[_checkYESButton setImage:[UIImage imageNamed:@"checkYESLeft.png"] forState:UIControlStateNormal];
self.checkYESButton.alpha = 1;
self.checkYESButton.frame = CGRectMake( -100, 185, 106, 90);
[UIView animateWithDuration:0.15f
delay:1
options:UIViewAnimationOptionCurveEaseInOut
animations:^
{
self.checkYESButton.center = CGPointMake(176, 185);
}
completion:^(BOOL finished)
{
}
同理我带了一个之前早没用过的按钮,按钮显示正常
更新
self.checkYESButton.hidden = NO;
[_checkYESButton setImage:[UIImage imageNamed:@"checkYESLeft.png"] forState:UIControlStateNormal];
self.checkYESButton.alpha = 1;
self.checkYESButton.frame = CGRectMake( -100, 185, 106, 90);
[UIView animateWithDuration:0.15f
delay:1
options:UIViewAnimationOptionCurveEaseInOut
animations:^
{
self.checkYESButton.center = CGPointMake(176, 185);
// code is below decide this situation (only in this line)
self.checkYESButton = [UIButton buttonWithType:UIButtonTypeCustom];
}
completion:^(BOOL finished)
{
}