我有一个 UITableViewCell 的子类,里面有按钮。该按钮有清晰的 backgroundColor
和一些边框。我想从按钮的中心开始填充动画。我的问题是动画立即完成。这是我的代码,我尝试以两种不同的方式执行此操作。
- (void)goingButtonAnimation {
UIView *goingButtonBackgroundView = [[UIView alloc] initWithFrame:CGRectMake(self.goingButton.center.x, self.goingButton.center.y, 0., 0.)];
goingButtonBackgroundView.layer.cornerRadius = 2.;
goingButtonBackgroundView.backgroundColor = [UIColor blackColor];
[self insertSubview:goingButtonBackgroundView belowSubview:self.goingButton];
[UIView animateWithDuration:2. animations:^{
goingButtonBackgroundView.frame = self.goingButton.frame;
}];
}
我也试过这个:
goingButtonBackgroundView.transform = CGAffineTransformMakeScale(0.1, 0.1);
[UIView animateWithDuration:2. animations:^{
goingButtonBackgroundView.transform = CGAffineTransformMakeScale(1.0, 1.0);
goingButtonBackgroundView.center = self.goingButton.center;
}];
但是在每种情况下动画都会立即完成。 goingButtonAnimation 方法在点击 self.goingButton
最佳答案
我的问题是在调用 goingButtonAnimation
之后我调用了 [self.tableView reloadData]
关于ios - UITableViewCell 中的动画立即完成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26662027/