【发布时间】:2014-03-12 17:11:02
【问题描述】:
我正在尝试使用 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;
}];
【问题讨论】:
-
您在该完成块中同时运行两个动画。第二个不应该在第一个的完成块中吗?
-
刚刚试过了,还是不行:(
-
sizeToFit 调用不应该真的存在,尽管我不确定它们会影响动画。 “不工作”是什么意思?
-
拿出来还是一无所获。不像在动画中那样工作实际上并没有动画。我已经在块中放置了其他测试动画,它们工作正常。所以我认为它与变换属性有关
-
展示如何
init你的self.monthLabel。
标签: ios objective-c animation uiview cgaffinetransform