如何为不同的重力行为设置不同的重力方向向量?

时间:2014-09-18 10:58:22

标签: ios iphone

I have two UIViews.i want to set different gravitydirection vector for these two views for making **attraction**.and i am doing this by having two gravitybehavior but when i am adding these two to animator.
it's not working as **attracting** to each other.
also giving warning like :-Multiple gravity behavior per animator is undefined and may assert in the future.
Below is the code i am using to make Attractiuon effect b/w two views.

重力行为是制作重力动画。动画师是动态动画师。

UIGravityBehavior *gravityBehavior = [[UIGravityBehavior alloc] initWithItems:@[v1]];

      CGVector vector = CGVectorMake(1.0, 1.0);

    [gravityBehavior setGravityDirection:vector];


    UIGravityBehavior *gravityBehavior1 = [[UIGravityBehavior alloc] initWithItems:@[v2]];
        CGVector vector1 = CGVectorMake(-1.0, -1.0);

    [gravityBehavior1 setGravityDirection:vector1];
    gravityBehavior.magnitude=1000;

       self.animator = [[UIDynamicAnimator alloc] initWithReferenceView:self.view];
    [self.animator addBehavior:gravityBehavior];
     [self.animator addBehavior:gravityBehavior1];

请帮忙! 谢谢你的帮助!

0 个答案:

没有答案