自动布局和使用动画期间计算的值

时间:2014-07-21 16:51:20

标签: ios cocoa-touch autolayout

我有一个视图(我们称之为A),它通过在animateWithDuration块中更改它的高度常量来设置动画,并且它有一个固定在它底部的子视图(B)。是否可以在A使用A的最终高度值完成动画之前设置B的位置?即是否有可能在实际动画之前使用A的最终点?

代码:

- (void)viewDidLoad
{
    [super viewDidLoad];
    ....
    viewA.addSubview(viewB);
    [viewA addConstraint:[NSLayoutConstraint constraintWithItem:viewB attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:viewA attribute:NSLayoutAttributeBottom multiplier:1.0f constant:0.0f]];
    ....
}

- (IBAction)buttonPressed
{
    ....
    //Here I want Auto Layout to immediately set viewB's final position, even though it relies on a's height constraint which is being animated
    [UIView animateWithDuration:0.5 animations:^
    {
        viewAHeightConstraint.constant += 50.0f;
    }];
    ....
}

0 个答案:

没有答案