storyboard拖线 改变NSLayoutConstrain

2020-04-27  本文已影响0人  段公子齐策二

以前用storyboard时候 把约束拖出来属性 改变约束时候 总是实现不了动画效果 用frame布局时候用UIView的动画却没问题 经过查询资料 发现需要用UIView的动画去执行layoutIfNeed 以键盘举例  代码如下

self.viewBottomLayout.constant = frame.size.height;

    //用layoutIfNeeded方法可以实现动画

    [UIView animateWithDuration:keyboardDuration animations:^{

           [self.view layoutIfNeeded];

    }];

上一篇 下一篇

猜你喜欢

热点阅读