0
我有一個UITableViewCell的子類,裏面有按鈕。該按鈕有一些邊框清除backgroundColor
。我想從按鈕的中心開始填充動畫。我的問題是動畫立即完成。這是我的代碼,我嘗試了兩種不同的方式。UITableViewCell中的動畫立即完成
- (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