CGAffineTransformMakeScale(0, 0)缩小动画的坑

最近的任务大多数是做UI和动画,今天遇到一个低级错误。

执行一个消失动画,把transform scale设置成0.0和0.0,打死动画都出不来,一直闪现

__weak __typeof__(self)weakSelf = self;
[UIView animateWithDuration:0.3f animations:^{
    __strong __typeof__(self)strongSelf = weakSelf;
    strongSelf.containerView.transform = CGAffineTransformMakeScale(0.0f, 0.0f);
    strongSelf.containerView.alpha = 0.0f;
} completion:^(BOOL finished) {
    [UIView animateWithDuration:0.3f animations:^{
        __strong __typeof__(self)strongSelf = weakSelf;
        strongSelf.alpha = 0.0f;
    } completion:^(BOOL finished) {
        if (completed) {
            completed();
        }
        __strong __typeof__(self)strongSelf = weakSelf;
        [strongSelf removeFromSuperview];
    }];
}];

查了老半天资料得知,CGAffineTransformMakeScalexy参数为零不会触发动画,直接就消失处理,把两个参数改大就好了

strongSelf.containerView.transform = CGAffineTransformMakeScale(0.01f, 0.01f);
strongSelf.containerView.alpha = 0.0f;
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 在iOS实际开发中常用的动画无非是以下四种:UIView动画,核心动画,帧动画,自定义转场动画。 1.UIView...
    请叫我周小帅阅读 3,179评论 1 23
  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 173,873评论 25 709
  • 先看看CAAnimation动画的继承结构 CAAnimation{ CAPropertyAnimation { ...
    时间不会倒着走阅读 1,700评论 0 1
  • 转载:http://www.cnblogs.com/jingdizhiwa/p/5601240.html 1.ge...
    F麦子阅读 1,601评论 0 1
  • 七绝--秋情【一】 **诗文/红尘一凡 老树一枝栖鸟鸦,寒风冷露浸农家。 谁知月里千光目,梦里悄然过榻纱。 七绝-...
    37度女人_8dda阅读 726评论 1 3