0
我試圖使用UIKit動態下移子視圖。我需要將子視圖移到特定位置,但它不起作用,它會一直沿着主視圖移動。這裏是我的代碼:UIKit Dynamics添加重力/碰撞/反彈來重定位子視圖
UIView *mySubview = [self.view viewWithTag:102];
self.animator = [[UIDynamicAnimator alloc] initWithReferenceView:self.view];
self.gravityBehavior = [[UIGravityBehavior alloc] initWithItems:@[mySubview]];
self.gravityBehavior.magnitude = 1;
[self.animator addBehavior:self.gravityBehavior];
self.collisionBehavior = [[UICollisionBehavior alloc] initWithItems:@[ mySubview]];
[self.collisionBehavior addBoundaryWithIdentifier:@"bottom"
fromPoint:CGPointMake(352, 233)
toPoint:CGPointMake(352,700)];
self.collisionBehavior.translatesReferenceBoundsIntoBoundary = YES;
[self.animator addBehavior:self.collisionBehavior];
self.bounceBehaviour = [[UIDynamicItemBehavior alloc] initWithItems:@[ mySubview]];
self.bounceBehaviour.elasticity = 0.6;
[self.animator addBehavior:self.bounceBehaviour];
我試圖做的是讓子視圖下去,反彈至我想在這種情況下的位置我想子視圖有這個最終奧利(352700)
你們誰都知道怎麼可以做到這一點?或工作?
我真的很感謝你的幫助。