2015-07-09 46 views
0

我正在使用masonry autolayout的项目,并且我在动画中遇到了一些问题,所以我必须做的事情是让一个抽屉出现从屏幕的顶部开始,将出现一个动画,因此容器视图的内容(可以是1视图或多个视图)是使用石匠视图添加的,我的问题是当我调试视图时,我得到的框架始终是Frame(0 0; 0 0)y因为我需要应用动画我需要框架来捕获容器视图的高度,有没有一种方法来获得正确的框架或它是一个特定的如何使用动画和自动布局?xcode masonry没有设置正确的框架

回答

0

尝试捕获viewDidLayoutSubviews中帧的高度为UIViewControllerlayoutSubviewsUIView

要为AutoLayout动画应用,你必须重新设置约束这样的:

// tell constraints they need updating 
[self setNeedsUpdateConstraints]; 

// update constraints now so we can animate the change 
[self updateConstraintsIfNeeded]; 

[UIView animateWithDuration:0.4 animations:^{ 
    [self layoutIfNeeded]; 
}]; 

和更新或改造updateConstraints的约束。

另请参阅:https://github.com/SnapKit/Masonry/blob/master/Examples/Masonry%20iOS%20Examples/MASExampleUpdateView.m

+0

非常感谢,它真的帮助我。 – user9898

+0

为什么不接受这个答案? :) – user3480295