代码之家  ›  专栏  ›  技术社区  ›  user1272965

UIKit Dynamics通过碰撞更改图幅

  •  0
  • user1272965  · 技术社区  · 7 年前

    我的项目有几个视图,它们在父视图的中心受径向重力和弹性碰撞的影响,因此它们不会重叠。它工作得很好,但有时我需要调整视图的大小,当一个视图变大时,其他视图必须离开它,以便所有视图保持不重叠。

    以下是我正在尝试的内容:

    [UIView animateWithDuration:0.5 animations:^{
        view.frame = CGRectInset(view.frame, -30, -30);
    } completion:^(BOOL finished) {
        [self.animator updateItemUsingCurrentState:view];
    }];
    

    我试着改变变换而不是帧-没有骰子。我试着从所有行为中删除视图-没有骰子。我试着从动画师身上去掉一些和所有的行为——没有骰子。我试过打电话 updateItemUsingCurrentState:

    你能帮忙吗?谢谢…(斯威夫特,请随意回答。我会翻译)

    1 回复  |  直到 7 年前
        1
  •  2
  •   user1272965    7 年前

    幸亏 this post

    [self.animator removeBehavior:self.behavior]; // for all behaviors that have view as an item
    
    [UIView animateWithDuration:0.5 animations:^{
        view.frame = CGRectInset(view.frame, -30, -30);
    } completion:^(BOOL finished) {
        [self.animator updateItemUsingCurrentState:view];
        [self.animator removeBehavior:self.behavior];
    }];