iOS开发笔记-Autolayout自动布局与UIView动画

使用了Autolaout的视图的动画

方法一:简单的说就是先找到想要变化的NSLayoutConstraint

然后改变constant值

    NSLayoutConstraint * _bottomCelectVLocRight;
        _bottomCelectVLocRight.constant = 0;

        [UIView animateWithDuration:.5 animations:^{
            
            [self.view layoutIfNeeded];
            
        }];
方法二:把你想要做动画的view的translatesAutoresizingMaskIntoconstraints为yes
        [UIView animateWithDuration:.5 animations:^{         
           _bottomCoolectView.translatesAutoresizingMaskIntoConstraints = YES;
            _bottomCoolectView.frame = CGRectMake(CGRectGetMinX(_bottomCoolectView.frame)-bottomCoolectViewWidth, CGRectGetMinY(_bottomCoolectView.frame), CGRectGetWidth(_bottomCoolectView.frame), CGRectGetHeight(_bottomCoolectView.frame));
                        
        }];

你可能感兴趣的:(iOS开发笔记)