首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >CGAffineTransform在UIView动画完成块中不起作用

CGAffineTransform在UIView动画完成块中不起作用
EN

Stack Overflow用户
提问于 2014-03-13 01:11:02
回答 1查看 924关注 0票数 0

我正在尝试使用transform属性为UILabel设置动画。它在主动画中似乎工作得很好。但是,一旦我尝试在主动画完成块中设置动画

代码语言:javascript
复制
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;
    }];
EN

回答 1

Stack Overflow用户

发布于 2017-03-29 03:17:09

您不需要解释变换动画的错误所在。但在我的例子中,转换根本不是动画,它会转换到最终状态,就像持续时间是0.0一样。我可以通过添加以下选项来修复它:

代码语言:javascript
复制
[UIView animateWithDuration:0.25 delay:0.0 options:UIViewAnimationOptionOverrideInheritedDuration|UIViewAnimationOptionOverrideInheritedCurve animations:^{
    // animate transform here
    } completion:^(BOOL finished) {
    // finished;
}];

如果有帮助,请告诉我。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/22358915

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档