我有以下代码,它只是将密码附加UITextField
到anchorPoint
. 当我运行它时,什么也没有发生。
UIDynamicItemBehavior *behavior =
[[UIDynamicItemBehavior alloc] initWithItems:@[passwordTextField]];
CGPoint anchor = passwordTextField.center;
anchor.y -= 200;
_attachment = [[UIAttachmentBehavior alloc] initWithItem:passwordTextField
attachedToAnchor:anchor];
_gravity = [[UIGravityBehavior alloc] initWithItems:@[passwordTextField]];
_gravity.magnitude = 10;
[behavior addChildBehavior:_gravity];
[behavior addChildBehavior:_attachment];
[_animator addBehavior:behavior];