ios - UITableViewCell 中的动画立即完成

标签 ios objective-c uitableview animation core-graphics

我有一个 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/

相关文章:

iphone - 界面方向旋转

iphone - 如何在 NSMutableArray 中创建查询并打印结果?

ios - 有没有办法在滑动单元格时从 tableViewCell 导航到另一个 View Controller ?

swift - 动态调整 UITableView 高度

iphone - [iPhone]如何自定义分组TableView中Section的标题?

objective-c - UI应用程序空闲计时器

android - 如何从另一个移动应用程序链接到 Twitter、Facebook 和 YouTube 应用程序?

ios - 如何将 UICollectionView 项目的大小调整为具有 Collection View 高度的正方形大小?

ios - Xcode 10、11 - 无法发出预编译 header

iphone - 将 XML 内容表示为 NSData - iPhone