使用UIDynamicAnimator后的模糊图像

时间:2014-06-02 20:30:55

标签: ios cocoa-touch uidynamicanimator

我使用UIDynamicsAnimator效果不错,但在动画完成后,已推送和弹回的图像模糊不清。请帮帮我。

@property (nonatomic,weak) IBOutlet UIImageView *someImage;

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

self.gravity = [[UIGravityBehavior alloc] initWithItems:@[self.someImage]];
CGVector gravityDirection = {-1.0, 0.5};
[self.gravity setGravityDirection:gravityDirection];

self.collision = [[UICollisionBehavior alloc] initWithItems:@[self.someImage]];
self.collision.translatesReferenceBoundsIntoBoundary = YES;

self.itemBehaviour = [[UIDynamicItemBehavior alloc] initWithItems:@[self.someImage]];
self.itemBehaviour.elasticity = 0.5;

[self.animator removeAllBehaviors]; // to avoid problems from the last behaviour animation

[self.collision addBoundaryWithIdentifier:@"barrier"
                               fromPoint:CGPointMake(444,0)
                               toPoint:CGPointMake(444,768)];

self.pushBehavior = [[UIPushBehavior alloc] initWithItems:@[self.someImage] mode:UIPushBehaviorModeInstantaneous];
self.pushBehavior.magnitude = 1.0f;
self.pushBehavior.angle = 0.0f;
[self.animator addBehavior:self.pushBehavior];

self.pushBehavior.pushDirection = CGVectorMake(1.0f, 0.0f)
self.pushBehavior.active = YES;

[self.animator addBehavior:self.itemBehaviour];
[self.animator addBehavior:self.collision];
[self.animator addBehavior:self.gravity];

1 个答案:

答案 0 :(得分:1)

我认为你的问题是图像在动画完成时没有精确点。我想知道你添加了一个委托,当动画暂停时,你将图像的x和y四舍五入到最接近的整数。