我正在尝试使用transform属性为UILabel设置动画。它在主动画中似乎工作得很好。但是,一旦我尝试在主动画完成块中设置动画
UILabel *dateLabel = [[UILabel alloc] initWithFrame:CGRectMake(point.x, point.y, 50, 20)];
dateLabel.text = [NSString stringWithFormat:@"%d", date];
dateLabel.textColor = [UIColor whiteColor];
dateLabel.textAlignment = NSTextAlignmentCenter;
[self addSubview:dateLabel];
[UIView animateWithDuration:.4 animations:^{
dateLabel.frame = CGRectMake(self.frame.size.width/2 - 25, 10, 50, 70);
self.calendar.frame = CGRectMake(0, 800, 320, 320);
dateLabel.font = [UIFont fontWithName:@"Bariol-Bold" size:28];
} completion:^(BOOL finished) {
[UIView animateWithDuration:.5 animations:^{
self.monthLabel.transform = CGAffineTransformMakeScale(1.2,1.2);
[self.monthLabel sizeToFit];
} completion:nil];
[UIView animateWithDuration:.5 animations:^{
self.monthLabel.transform = CGAffineTransformMakeScale(1.15,1.15);
[self.monthLabel sizeToFit];
} completion:nil];
calendarAnimation = NO;
}];发布于 2017-03-29 03:17:09
您不需要解释变换动画的错误所在。但在我的例子中,转换根本不是动画,它会转换到最终状态,就像持续时间是0.0一样。我可以通过添加以下选项来修复它:
[UIView animateWithDuration:0.25 delay:0.0 options:UIViewAnimationOptionOverrideInheritedDuration|UIViewAnimationOptionOverrideInheritedCurve animations:^{
// animate transform here
} completion:^(BOOL finished) {
// finished;
}];如果有帮助,请告诉我。
https://stackoverflow.com/questions/22358915
复制相似问题