• 如何解决IOS 动画中 Autolayout 与View Transforms的冲突


    IOS 的动画放大与缩小,并非按照找它的中心点放大和缩小,而是左上角 。我分析了下原来是Autolayout 与View Transforms的冲突造成的。

     

    - (void) addSubviewWithZoomInAnimation:(UIView*)view duration:(float)secs option:(UIViewAnimationOptions)option
    {
    // first reduce the view to 1/100th of its original dimension
    CGAffineTransform trans = CGAffineTransformScale(view.transform, 0.01, 0.01);
    view.transform = trans;    // do it instantly, no animation
    [self addSubview:view];
    // now return the view to normal dimension, animating this tranformation
    [UIView animateWithDuration:secs delay:0.0 options:option
    animations:^{
    view.transform = CGAffineTransformScale(view.transform, 100.0, 100.0);
    }
    completion:nil];    
    }
    
    - (void) removeWithZoomOutAnimation:(float)secs option:(UIViewAnimationOptions)option
    {
    [UIView animateWithDuration:secs delay:0.0 options:option
    animations:^{
    self.transform = CGAffineTransformScale(self.transform, 0.01, 0.01);
    }
    completion:^(BOOL finished) { 
    [self removeFromSuperview]; 
    }];
    }



     

    解决方案: 

    Disable auto layout:

    self.imageView.translatesAutoresizingMaskIntoConstraints = YES;

     

    【1】

    http://stackoverflow.com/questions/12943107/how-do-i-adjust-the-anchor-point-of-a-calayer-when-auto-layout-is-being-used/14105757#14105757

  • 相关阅读:
    oracle的nvl函数的用法
    简单实用的MD5加密算法
    oracle触发器使用笔记
    Html学习
    连接字符串
    oracle触发器使用笔记2
    oracle中如何给有空值的数据排序
    Zend Frame 添加Smarty模板引擎
    HDU 2464 A Pair of Graph
    POJ 1466 Girls and Boys
  • 原文地址:https://www.cnblogs.com/rubick/p/3694719.html
Copyright © 2020-2023  润新知