Ios 引起失真的行为
无论出于何种原因,每当我使用捕捉行为时,它都会导致UIButtons在“捕捉”时变成各种大小的矩形。我可能只是在仔细考虑这个问题。我的最后期限是明天,以得到最后的错误解决,所以我将非常感谢任何帮助!谢谢大家! vvv-ViewController.m-vvvIos 引起失真的行为,ios,objective-c,Ios,Objective C,无论出于何种原因,每当我使用捕捉行为时,它都会导致UIButtons在“捕捉”时变成各种大小的矩形。我可能只是在仔细考虑这个问题。我的最后期限是明天,以得到最后的错误解决,所以我将非常感谢任何帮助!谢谢大家! vvv-ViewController.m-vvv //set points CGPoint bullyboxPoint = {80, 188}; CGPoint weemPoint = {240, 188}; CGPoint yeaPoint = {80, 339}; CGPoint ch
//set points
CGPoint bullyboxPoint = {80, 188};
CGPoint weemPoint = {240, 188};
CGPoint yeaPoint = {80, 339};
CGPoint charityPoint = {240, 339};
CGPoint phhsPoint = {80, 488};
CGPoint experiencePoint = {240, 488};
//make the buttons closer to speed up the snap
bullybox.frame = CGRectMake(40, 788, 120, 120);
weem.frame = CGRectMake(200, 788, 120, 120);
yea.frame = CGRectMake(30, 939, 120, 120);
charity.frame = CGRectMake(190, 939, 120, 120);
phhs.frame = CGRectMake(20, 1328, 120, 120);
experience.frame = CGRectMake(180, 1328, 120, 120);
//create behaviors
UISnapBehavior *snapBehavior = [[UISnapBehavior alloc] initWithItem:self->bullybox snapToPoint:bullyboxPoint];
UISnapBehavior *snapBehavior1 = [[UISnapBehavior alloc] initWithItem:self->weem snapToPoint:weemPoint];
UISnapBehavior *snapBehavior2 = [[UISnapBehavior alloc] initWithItem:self->yea snapToPoint:yeaPoint];
UISnapBehavior *snapBehavior3 = [[UISnapBehavior alloc] initWithItem:self->charity snapToPoint:charityPoint];
UISnapBehavior *snapBehavior4 = [[UISnapBehavior alloc] initWithItem:self->phhs snapToPoint:phhsPoint];
UISnapBehavior *snapBehavior5 = [[UISnapBehavior alloc] initWithItem:self->experience snapToPoint:experiencePoint];
//dampen the snap
snapBehavior.damping = 1.2f;
snapBehavior1.damping = 1.2f;
snapBehavior2.damping = 1.2f;
snapBehavior3.damping = 1.2f;
snapBehavior4.damping = 1.2f;
snapBehavior5.damping = 1.2f;
//add behaviors
[self.animator addBehavior:snapBehavior];
[self.animator addBehavior:snapBehavior1];
[self.animator addBehavior:snapBehavior2];
[self.animator addBehavior:snapBehavior3];
[self.animator addBehavior:snapBehavior4];
[self.animator addBehavior:snapBehavior5];
问题可能是您正在使用自动布局。Autolayout和UIKit Dynamics是敌人(如果你看一下苹果的示例代码,你会发现他们通过关闭Autolayout绕过了这个问题) 我想解决这个问题的方法是:制作要设置动画的对象的快照图像;隐藏实际对象,并将快照图像放置到位;为快照图像设置动画;一切结束后,将快照图像从界面中取出,并在新位置显示实际对象 这是因为快照图像不受自动布局的约束。但是,您仍然需要解决这个问题,因为您无法通过设置按钮的
帧来移动受自动布局约束的按钮;您必须设置它们的约束