首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用界面生成器时的UIKitDynamics

使用界面生成器时的UIKitDynamics
EN

Stack Overflow用户
提问于 2014-08-07 00:41:52
回答 1查看 74关注 0票数 0

我想用UIKitDynamics给一些按钮添加动画,但是用UISnapBehaviour做一些非常基础的事情根本不起作用。我使用IB来布局我所有的子视图,所以请记住,我不能通过调用self.button.frame来重新定位任何东西,您必须使用约束。

这就是说,我在这里have...When,我运行动画,它很快地闪烁,看起来很糟糕。

代码语言:javascript
复制
// Position the buttons off screen
        self.swerveButton.translatesAutoresizingMaskIntoConstraints = NO;
        self.followButton.translatesAutoresizingMaskIntoConstraints = NO;
        self.swerveButtonTopSpaceConstraint.constant = -200;

        CGPoint swerveSnapPoint = self.swerveButton.center;
        CGPoint followSnapPoint = self.followButton.center;

        UISnapBehavior *followSnap = [[UISnapBehavior alloc] initWithItem:self.followButton
                                                              snapToPoint:followSnapPoint];

        UISnapBehavior *swerveSnap = [[UISnapBehavior alloc] initWithItem:self.swerveButton
                                                              snapToPoint:swerveSnapPoint];


        [self.overlayView fadeInWithDuration:0.2 completion:^{
            swerveSnap.damping = 0.3;
            [self.animator addBehavior:swerveSnap];

            followSnap.damping = 0.3;
            [self.animator addBehavior:followSnap];
        }];
    }
EN

回答 1

Stack Overflow用户

发布于 2014-08-07 00:49:36

UIKitDynamics不能与约束一起工作。如果你想使用它们,你将不得不走老路,手动设置帧,至少在动画过程中是这样。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/25165694

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档